Ethereum: How to get which tokens have been transferred by a transaction using ethers or Web3?

Receive tokens transfers on Ethereum using Eteres and Web3

In the Decentralized Finance World (Defi), Blockchain technology allows safe and transparent transactions. Among the many cryptocurrencies available, Ethereum is one of the most popular platforms for creating intelligent contracts and interacting with decentralized applications (DAPs). Regarding marker transfer tracking, Ethereum’s native functionality can be quite complicated, but there are ways to get this information using Eteres and Web3.

Understanding the ERC721 Tokens

Before we dive into the decision, let’s look briefly what the ERC721 tokens are. The ERC721 is the standard for creating non -marky tokens (NFTS) in blockchain Ethereum. These NFTs are unique digital actives, such as art, collectibles or articles in the game. When a transaction occurs involving the ERC721 marker, you want to know how many times this specific marker has been transferred from a specific portfolio or address.

Receive transfers from markers using Euters

Ethereum: How to get which tokens have been transferred by a transaction using ethers or Web3?

To get the number of transfer to a specific ERC721 marker from a transaction, you can use the features of constructed etheres. Here is a step guide:

  • Get transaction data : First, you need to recover data from transactions related to the Ethereum network. You can do this by sending the “Eth_getTransaction” request to the Ethereum API using the “Web3library.

JavaScript

CONST Web3 = Requirement (‘Web3’);

CONST ETHERS = Requires (‘Web3’);

CONST Web3instance = new Web3 (New Web3.Providers.httpProvider (‘

CONST TRANSACTION = Wait by Web3instance.eth.getTransctionByhash (‘0x …’); // Replace with a hash of your transaction

CONSTT CONTRACTADDRESS = ‘0x …’; // ERC721 marker contract address

`

  • I agree with the agreement ABI : Before receiving the number of transfers, you must receive ABI (a binary application interface) of the TERERC721 contract.

`JavaScript

transaction.abi.foreach (bytecode) => {

Consta abbi = json.pass (bytecode.tostring ());

// Get the name and symbol of the ERC721 marker of your abi

CONSTRSNAME = Abi.Name;

CONSTR CONTRESSYMBOL = Abi.symbol;

});

`

  • Get the number of transfers : You can now use the countertelddress to get the number of transfers using the constructed -in -the -eet,eth_getTransforcount.

`JavaScript

CONST TRANSFERCOUN = Wait for euteres.getContrentinfoasync (ContractAddress, ‘Balancef’);

`

Receive markers transferred using web3

Although Ether provides an easier way to recover transaction data and contract information, Web3 offers additional functions for smart intelligent contracts.

To get the number of transfers from ERC721 markers from an Ethereum’s specific portfolio or address, you can use the eths of the eths eth_getTransactationCount with the following parameters:

* Chainid : The target chain id (for example, for Ethereum Mainnet)

* TRANSACTIONHASH : Transaction hash

* Contractaddress : Address of contract ERC721

JavaScript

CONST Web3instance = new Web3 (New Web3.Providers.httpProvider (‘

CONST TRANSACTIONHASH = ‘0x …’; // Replace with a hash of your transaction

CONSTT CONTRACTADDRESS = ‘0x …’; // ERC721 marker contract address

CONST TRANSFERCOUN = Wait for euteres.getContratinfoasync (ContractDdress, ‘Balancef’, {

Chainid: Web3instance.eth.net === ‘Mainnet’? 1: Web3instance.eth.net,

Transacthonhash,

});

`

Conclusion

In short, you can recover information about the number of transfers to the ERC721 marker from a specific portfolio or Ethereum address using eetres. Understanding how to bring transaction data and ABI contract, as well as using `Eth_getTransCionCount ‘on Web3, you can get this valuable information.

ethereum binance calculation


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *