Skip to main content

ERC721 Contracts

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

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

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

image

  1. Start the transformers program,Restart the transformers node program in the menu bar.
 ./tfs_v0.32.0_xxxx_testnet -m
  1. In the transformers node program, choose to execute 8. 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.

  1. 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 input your choice:
9

Addrlist :
0x384C4444Ac5aD074B61Db7013F7062a73767b243 [default]
Please enter your addr:
0x384C4444Ac5aD074B61Db7013F7062a73767b243
================deployers=========================
deplover: 0x384C4444Ac5aD074B61Db7013F7062a73767b243
================deployers=========================
Please enter to addr:
0x6c1c72fc3ad77a66c78B881Ca77dD6CbFD2B1e66
================deployed utxo=========================
deployed utxo:4cb93b5b624c99edc6285f44ed3fdbff927ed87b8fea27f4c6985c0f9385fo
================deployed utxo=========================
Please enter tx hash:
4cb93b5b624c99edc6285f44ed3fdbff927ed87b8fea27f4c6985c0f9385f0c4Please
enter args:
0x70a08231000000000000000000000000617f2e2fd72fd9d5503197092ac168c91465e7f21
input contract tip amount :
1
input contract transfer amount :
0

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