Based on block chain locations (MOAC BlockChain), using MOAC web wallet deployment ERC - 721 contracts, realize the corresponding digital operation,
Environment:
Stone block chain version: nvwa - vnode1.0.2. Win. Zip.
Operating system: 64 - bit Windows 10 home edition,
1. Install and start a local node
1.1 installation moac node
Please refer to the document "the third block chain locations (MOAC BlockChain) node installation tutorial",
1.2 start moac node
Open a command terminal (CMD), go to the current directory locations, executed on the command line:
D: \ nuwa1.0.2. Win> Moac, RPC, rpccorsdomain "http://wallet.moac.io"
Note:
- the RPC start RPC service, native access node
- rpccorsdomain starts the browser to access the service, the native access node
"Http://wallet.moac.io" moac wallet online web site, will be automatically connected to the machine start moac node and display the existing accounts, if the machine has not started, displays the following message,
Start normal, displays the following account information, to ensure that one of the account has enough moac for intelligent deployment contract,
2. Write and compile intelligence
2.1 the following is based on erc - 721 a scrip written contract
In this paper, the actual test code TestToken721. Sol attached at the end of the article,
Note: the code to use for test case, the standard deployment of intelligent contract code,
2.2 compile, deploy
The web wallet click CONTRACTS button "CONTRACTS"
Then click DEPLOY NEW contracts button "DEPLOY NEW CONTRACT
"
Choose a moac balance account,
Put smart contracts to write your own code in the code area "Solidity contract source code", the code will automatically compile, if compiled through, will be displayed on the right side "the Select contract to deploy,"
If the compiler does not pass, does not show the corresponding contents,
In the "Select contract to deploy" drop-down box to Select the corresponding token type, this case is "token Demo",
After choose gas fee, click on the "DEPLOY" deployment of contracts, contract confirmation screen released will be displayed at this time,
If prompted for unlock (deployment of smart contracts) account, enter the moac command line interface, enter the command:
The personal unlockAccount (MC) accounts [0], "passwd", 300)
There are three parameters: the command
The first parameter to unlock account,
The second parameter is the account password,
The third parameter is the time to unlock, this example is 300 seconds, will lock the account again after 300 seconds;
If the unlock time to 0, said has been unlocked, accounts at this time there are risks, careful,
In order to hide the password, can enter the command:
The personal unlockAccount (MC) accounts [0])
After enter prompted for a password, the password is not displayed, this command will default to account unlock 300 seconds,
Success will unlock returns true, released at this time will show the contract confirmation interface,
Note: must have the Data in the Data, otherwise can't normal deployment
Click on "OK", started deploying contracts, interface beneath the progress bar will display the current deployment contracts
Progress bar confirmed 12 blocks, said deployed,
Click on the successful deployment of the contract, you can see the basic content, including contract address hash, are included in the block number, etc.,
Login moac block chain browser: http://explorer.moac.io/home, in tokens drop-down box to choose "View ERC721",
In the search bar enter contracts address, can search to the corresponding contents of the contract,
Click go in, you can see basic information about contract, Token Transfers and Token Holders information,
Note: this step may need to have a trade to the query browser,
At this point, can confirm contract deployment is successful,
3. The token of the transaction
3.1 check the contract status
Click "on the deployed contract progress bar Token Demo page (management)", enter the contract management interface,
The upper part shows the basic information of the management interface, the contract is address, general function button on the right, mainly includes: receiving and painters and token, the browser view, copy the address, qr code and display interface,
Click on "display interface", jump out of the following interface, display "contract JSON interface", if there are others need to manage or operate this smart contract, you need the interface content along with contract address a and sent to him,
The lower part of the management interface according to the contract itself function,
One on the left shows the read operation contract, in this case, including name, according to the query tokenID owner account, such as query balance according to the account,
The right to contract the write operation, simple to understand is the public function of the contract,
In this case, the current did not create a token, so 721 of the contract token number is 0,
3.2 to create the first erc721 digital assets
In this example, Create a token is a written contract operation, the select function drop-down box on the right to select "Create token", fill in the parameters and the owner address, click on the "EXECUTE",
Here the parameters of the property is the content in the data structure, the user can according to own actual need in the contract in multiple fields,
Interface prompt transaction "send",
If the tip need to unlock the account, please refer to the previous steps unlock operation,
After writing block, can read operation interface to query, as shown in the figure below:
Above, in the index 0 interface, display has the first 721 token contract (contract the index number starts at 0, every time when created, the index number automatically incrementing) address, this case is given priority to account,
Enter an account in the owner, automatically displays the number of token account currently has
3.3 trade erc721 digital assets
In this case, send the token is a written contract operation, the select function drop-down box on the right to select "Transfer", fill in the receiving address and send the index number, choose account, click on the "EXECUTE", if the account with the token, will send success; If the account does not have the token, the operation and no error message here, just don't have a real trading,
After the success of the deal, on the left side of the contract will automatically update the read operation, the index number of 0 token with a new owner, and the owner of a token amount will automatically reduce 1, the new owner will automatically increase the number of 1,
In the main interface, will display all of your accounts and their digital assets owned by a
At this point, a typical ERC - 721 intelligent deployment completed contract,
ERC - 721 intelligent contract can and with uniqueness of assets in the real life, has a broad application prospect,
Attachment:
Used in this article the contract code TestToken721 sol,
Note: the code to use for test case, the general intelligent contract code,
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull