Authorization Required
5 stars based on
47 reviews
This section will further elaborate what you can do with contracts and transactions building on a protocol NatSpec. Solidity implements smart comments doxigen style which then can be used to generate various facades meta documents of the code. One such use case is to generate custom messages for transaction confirmation that clients can prompt users with.
So we now extend the multiply7 contract with a smart comment specifying a custom confirmation message notice. The comment has expressions in between backticks which are to be evaluated at the time the transaction confirmation message is presented to the user. The variables that refer to parameters of method calls then are instantiated in accordance with the actual transaction data sent by the user or the user's dapp. NatSpec support for confirmation notices is fully implemented in geth.
NatSpec relies on both the abi definition as well as the userDoc component to generate the proper confirmations. Therefore in order to access that, the contract needs to have registered its contract info as described above.
Let us see a full example. As a very conscientious smart contract dev, you first create your contract and deploy according to the recommended steps above:. Note that if we use content addressed storage system like swarm the second step is unnecessary, since the contenthash is deterministically translates to the unique address of the content itself.
For the purposes of a painless example just simply use the file url scheme not exactly the cloud, but will show you how it works without needing to deploy. Now you are done as a dev, so swap seats as it were and pretend that you are a user who is sending a transaction to the infamous multiply7 contract.
You need to start the client with the --natspec flag to enable smart confirmations and contractInfo fetching. You can also set it on the console with admin.
When this transaction gets included in a block, somewhere on a lucky miner's computer, 6 will get multiplied by 7, with the result ignored. This accumulates all the transactions sent, even the ones that were rejected and are not included in the current mined block trans state. These latter can be shown by:. Ethereum Frontier Guide Introduction 0. The Frontier Release 0. Installing and running a node 1.
Connecting to the network 1. Monitoring your nodes 1. Setting up a cluster 2. Importing your presale wallet 2. Listing accounts and checking balances 2. CPU mining with geth 3. Command line interface and options 4. Contracts and transactions 5. Account types and transactions 5. Writing a contract 5. Compiling a contract 5. Creating and deploying a contract 5. Gas and transaction costs 5. Interacting with contracts 5. Contract info metadata 5. Testing contracts and transactions 5. DevP2P protocol spec 6.
Contract info metadata 6. Application Binary Interface 6. Opcodes, costs, and gas Published with GitBook. NatSpec This section will further elaborate what you can do with contracts and transactions building on a protocol NatSpec. As a very conscientious smart contract dev, you first create your contract and deploy according to the recommended steps above: Will multiply 6 by 7.
If the transaction is not picked up, we can see it with: These latter can be shown by: