IMG-LOGO

Contract Execution on TFSC

sak1e - 2023-12-17 20:39:51


  • ContractAddress and EvmAddress.
ContractAddress is used for regular money transfer transactions, such as money transfer.
EvmAddress is used to interact with the contract, such as passing it as a parameter when calling a contract function.


Contract Execution



  1. Open the Remix IDE, enter the deployment menu, Click [Deploy] and the deployed contracts will appear in Deployed Contracts.

  2. Unfold the details of contract deployment to see the functions that support external calls.


1c-12-11f4de34701dd441ca481dd7f561d01e.png



  1. According to official document,it can be seen that balanceOf is used to obtain the token balance of a specific address.


2download.png



  1. Enter the account address that interacts with the contract (a string of 20 byte hexadecimal numbers), and click Calldata to obtain the encoded function parameters. By using this parameter, the token balance of an account can be obtained after executing the contract.


3c-13-c2c91a3d17edb33c649ac950f2a3113f.png



  1. Run the node program in menu mode and press 9 to execute the contract. First, enter the account of the Contract Executor, and then enter the account of the Contract Deployer,the transaction hash generated by all contracts deployed by the deployer will be displayed.


4c-14-76e36ba608ef93138acfa5afba50e007.png



  1. Copy the transaction hash of the contract to be executed, you can complete the execution of the contract by entering the encoded function parameters obtained in step 4, the tip to be paid to the contract deployer, and the fee to be paid to the contract.


5c-15-efe788b07ed3ea5e628d89e3495d21b3.png


The above only demonstrates the operation of executing a contract to check an account balance. If you want to perform other operations, you need to be familiar with the functions or methods written in the contract and carry out the corresponding operations.
ERC721 contract deployment Example
Preparation



  1. Write your ERC721 contract source code

  2. Open the compilation contract tool: Remix

  3. Prepare your node server and successfully deploy the transformers program.
    We take the ERC-721 from solidity by example as a demonstration.
    Contract Deployment

  4. Use Remix to compile the contract source code.Open the Remix tool. Paste your ERC721 contract source code into Remix and compile it.

  5. The most important thing to execute a contract in transformers is to get the input bytecode, which indicates which interface you need to implement in the contract and what parameters need to be passed.

  6. Obtain contract Bytecode and ABI,After Remix is successfully compiled, get the generated contract bytecode (Contract bytecode) and ABI. This information will be used in the subsequent deployment and execution of the contract. 


6erc721-1-bfb791c94827cddea39378c8defb4dbb.png



  1. Create a deployment preparation file,When the transformers node program is started, a folder named contract will be generated in the same directory as the program. Go into the contract folder and create a file called contract.txt to store the compiled bytecode of the contract.

  2. Write the contract bytecode to the file,Copy and paste the contract bytecode obtained in Remix into the contract.txt file.After saving and exiting.


7erc20-4-38ebc3ef60f2df993863b72576633c1e.png



  1. Start the transformers program,Restart the transformers node program in the menu bar.




  2. In the transformers node program, choose to execute8. Deploy contract operation. The address displayed by default is the wallet address of the deployer.
Fill in the relevant information as prompted. If the initial input is a contract bytecode without parameters, fill in the parameter bytecode; otherwise fill in 0.


  3. Deployment complete
    After the contract is successfully deployed, you will get the deployment address of the contract and the hash of the deployed contract.



Contract Execution
To execute a contract, you first need to be familiar with the internal parameters and methods of the contract. The following example uses the mint function as an example to call the contract to complete NFT casting.



  1. In the transformers node program, choose to perform the 9. Call contract operation.

  2. Fill in the relevant information for executing the contract according to the interface and parameters of the contract, and complete the steps of executing the contract.


9erc721-2-f5540a48955ca04dabe737453386a415.png


[Please enter args] with the bytecode of the execution method filled in.
After completing the content one by one, the contract was successfully executed and a mint operation was completed.