Imaginity with the tokens erc-721 with the SDK SAFE: Handmade
Language Solid Programing Ethereum, built on the poem of the virtual machine Ethereum (EVM), substitute a set of library and instruments for eaten components ecosystem. Such component is the standard tokens erc-721, which brings out the strokes, manage and transfer unique cipher actions that nft.
In this state, we dissatisfied with how to make it with chips erc-721, using the SDK SAFE, the library, which is the process of dentralized adjusts (DAPPS).
ERC-721 SOCE TOKEN PRESENTATION
We will be substituted for the fact that you can make it with the Erc-721 chips, let's take a quick time that they are: they are:
- Token erc-721-is a unique cytro activity that can be hidden, transfer and traded on the Ethereum blockchain.
- E. ERC-721 token has a unique identifier called "Token ID".
- Chips can be presented for the part, from the articulation, and their shadows and the use of strongly calculated.
SDK SAFE: MUCH CE COKNS ERC-721
The SDK is an indifference to the set of functions for mesimality with ecosystem ethereum components. In order to assemble with the chips erc-721 with the SDK SAFE, you need to use the library ethers.js' in front of the sdk.
Here's the primer how you can use the SDK SAFE for the transfer, transfer and sbalanschoi chips erc-721:
Javascript
// IMPORT NUMBERS
Const ethers = stabbed ('eates');
Const confedk = termes ('@safe-sdk/ethereum-safe-sdk');
// Setting up the ethereum post (for example, infura or alchemy)
Const soplor = new ethers.providers.jsonrpcpcprvider ('http: // localhost: 8545'); // or '
// Record address address ERC-721
Const ERC721Contractaddress = '0x ...'; // Outline the token address
// Retire all tokens accessed on blockchain
Safesdk.gettokens (). Then (tokens => {
constanids = tokens.map (token => token.id);
// STIUTE CONDITED SIMBOL AFTER IDENTIFTER
Safesdk.gettoken ('0x ...'). Then (token => {
Console.log (Token Naiden with ID: $ {TOKEN.ID});
// Transempeter Imushchya cheris token on the second address
Safesdk.transferonher (Erc721Contracraddress, '0x ...', {from: 0x ... '}). Then (() => {
console.log ('token firmly overnex');
}). Swaymat (error => {
Consoles.error ('ribbons overdue:', scoop);
});
});
// Retirement of the Beder all chips
Safesdk.getbalans (). Then (balance => {
Const Balanceres = Balances.map (Balance => Balance.balance);
Console.log (tokens accessed with them:);
Console.log (Balanceres);
});
});
In this one, we made the simple ethereum postpartum and the addresses of the address ERC-721. We use theGetokens ()for the removal of all the ideant-to-token ERC-721, accessed to the blockchain.
To find a specific token by ID, we use the function Getoken ()
. In this case, we just pursue to 0x ID ...
Token.
As for the overnexation of the one -to -the second address, we use the function "Transforhownership ()". We go to the contract of the contract ERC-721, the address of the new vladel and the object of JSON, which preserves the property "from" and "all".
Again, to translate all the chips, we use the function of GetBalans ()
.
Immediately with the tokens erc-20
In that time, the SDK SAFE provides an interface for the eatery with the erc-721, he does not provides a predatory deposit with the erc-20 chip. The topic is not less, you can all understand the same library for the restoration of these ones, using the follow -up code:
`` Javascript
// IMPORT NUMBERS
Const ethers = stabbed ('eates');
Const confedk = termes ('@safe-sdk/ethereum-safe-sdk');
// Setting up the ethereum post (for example, infura or alchemy)
Postener Const = New Ethers.Providers.