Contract Execution on TFSC

0 23
Avatar for Sak1e_
Written by
10 months ago
  • 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.

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

  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.

  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.

  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.

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

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

  2. 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.

  3. 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. 

  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.

  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.

[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.

2
$ 0.00
Avatar for Sak1e_
Written by
10 months ago

Comments