@@ -46,20 +46,20 @@ explanatory purposes.
46
46
// to the language.
47
47
" compiler" : {
48
48
// Required for Solidity: Version of the compiler
49
- " version" : " 0.4.6 +commit.2dabbdf0.Emscripten.clang " ,
49
+ " version" : " 0.8.2 +commit.661d1103 " ,
50
50
// Optional: Hash of the compiler binary which produced this output
51
51
" keccak256" : " 0x123..."
52
52
},
53
- // Required: Compilation source files/source units, keys are file names
53
+ // Required: Compilation source files/source units, keys are file paths
54
54
" sources" :
55
55
{
56
- " myFile.sol" : {
56
+ " myDirectory/ myFile.sol" : {
57
57
// Required: keccak256 hash of the source file
58
58
" keccak256" : " 0x123..." ,
59
59
// Required (unless "content" is used, see below): Sorted URL(s)
60
- // to the source file, protocol is more or less arbitrary, but a
61
- // Swarm URL is recommended
62
- " urls" : [ " bzzr ://56ab ..." ],
60
+ // to the source file, protocol is more or less arbitrary, but an
61
+ // IPFS URL is recommended
62
+ " urls" : [ " bzz-raw ://7d7a... " , " dweb:/ipfs/QmN ..." ],
63
63
// Optional: SPDX license identifier as given in the source file
64
64
" license" : " MIT"
65
65
},
@@ -73,7 +73,7 @@ explanatory purposes.
73
73
// Required: Compiler settings
74
74
" settings" :
75
75
{
76
- // Required for Solidity: Sorted list of remappings
76
+ // Required for Solidity: Sorted list of import remappings
77
77
" remappings" : [ " :g=/dir" ],
78
78
// Optional: Optimizer settings. The fields "enabled" and "runs" are deprecated
79
79
// and are only given for backwards-compatibility.
@@ -100,15 +100,15 @@ explanatory purposes.
100
100
}
101
101
},
102
102
" metadata" : {
103
- // Reflects the setting used in the input json, defaults to false
103
+ // Reflects the setting used in the input json, defaults to " false"
104
104
" useLiteralContent" : true ,
105
105
// Reflects the setting used in the input json, defaults to "ipfs"
106
106
" bytecodeHash" : " ipfs"
107
107
},
108
- // Required for Solidity: File and name of the contract or library this
108
+ // Required for Solidity: File path and the name of the contract or library this
109
109
// metadata is created for.
110
110
" compilationTarget" : {
111
- " myFile.sol" : " MyContract"
111
+ " myDirectory/ myFile.sol" : " MyContract"
112
112
},
113
113
// Required for Solidity: Addresses for libraries used
114
114
" libraries" : {
@@ -118,12 +118,66 @@ explanatory purposes.
118
118
// Required: Generated information about the contract.
119
119
" output" :
120
120
{
121
- // Required: ABI definition of the contract
121
+ // Required: ABI definition of the contract. See "Contract ABI Specification"
122
122
" abi" : [/* ... */ ],
123
+ // Required: NatSpec developer documentation of the contract.
124
+ " devdoc" : {
125
+ " version" : 1 // NatSpec version
126
+ " kind" : " dev" ,
127
+ // Contents of the @author NatSpec field of the contract
128
+ " author" : " John Doe" ,
129
+ // Contents of the @title NatSpec field of the contract
130
+ " title" : " MyERC20: an example ERC20"
131
+ // Contents of the @dev NatSpec field of the contract
132
+ " details" : " Interface of the ERC20 standard as defined in the EIP. See https://eips.ethereum.org/EIPS/eip-20 for details" ,
133
+ " methods" : {
134
+ " transfer(address,uint256)" : {
135
+ // Contents of the @dev NatSpec field of the method
136
+ " details" : " Returns a boolean value indicating whether the operation succeeded. Must be called by the token holder address" ,
137
+ // Contents of the @param NatSpec fields of the method
138
+ " params" : {
139
+ " _value" : " The amount tokens to be transferred" ,
140
+ " _to" : " The receiver address"
141
+ }
142
+ // Contents of the @return NatSpec field.
143
+ " returns" : {
144
+ // Return var name (here "success") if exists. "_0" as key if return var is unnamed
145
+ " success" : " a boolean value indicating whether the operation succeeded"
146
+ }
147
+ }
148
+ },
149
+ " stateVariables" : {
150
+ " owner" : {
151
+ // Contents of the @dev NatSpec field of the state variable
152
+ " details" : " Must be set during contract creation. Can then only be changed by the owner"
153
+ }
154
+ }
155
+ " events" : {
156
+ " Transfer(address,address,uint256)" : {
157
+ " details" : " Emitted when `value` tokens are moved from one account (`from`) toanother (`to`)."
158
+ " params" : {
159
+ " from" : " The sender address"
160
+ " to" : " The receiver address"
161
+ " value" : " The token amount"
162
+ }
163
+ }
164
+ }
165
+ },
123
166
// Required: NatSpec user documentation of the contract
124
- " userdoc" : [/* ... */ ],
125
- // Required: NatSpec developer documentation of the contract
126
- " devdoc" : [/* ... */ ]
167
+ " userdoc" : {
168
+ " version" : 1 // NatSpec version
169
+ " kind" : " user" ,
170
+ " methods" : {
171
+ " transfer(address,uint256)" : {
172
+ " notice" : " Transfers `_value` tokens to address `_to`"
173
+ }
174
+ },
175
+ " events" : {
176
+ " Transfer(address,address,uint256)" : {
177
+ " notice" : " `_value` tokens have been moved from `from` to `to`"
178
+ }
179
+ }
180
+ }
127
181
}
128
182
}
129
183
@@ -160,7 +214,7 @@ to the end of the deployed bytecode
160
214
0x00 0x33
161
215
162
216
So in order to retrieve the data, the end of the deployed bytecode can be checked
163
- to match that pattern and use the IPFS hash to retrieve the file.
217
+ to match that pattern and the IPFS hash can be used to retrieve the file (if pinned/published) .
164
218
165
219
Whereas release builds of solc use a 3 byte encoding of the version as shown
166
220
above (one byte each for major, minor and patch version number), prerelease builds
@@ -184,14 +238,15 @@ Usage for Automatic Interface Generation and NatSpec
184
238
====================================================
185
239
186
240
The metadata is used in the following way: A component that wants to interact
187
- with a contract (e.g. Mist or any wallet) retrieves the code of the contract,
188
- from that the IPFS/Swarm hash of a file which is then retrieved. That file
241
+ with a contract (e.g. a wallet) retrieves the code of the contract.
242
+ It decodes the CBOR encoded section containing the IPFS/Swarm hash of the
243
+ metadata file. With that hash, the metadata file is retrieved. That file
189
244
is JSON-decoded into a structure like above.
190
245
191
246
The component can then use the ABI to automatically generate a rudimentary
192
247
user interface for the contract.
193
248
194
- Furthermore, the wallet can use the NatSpec user documentation to display a confirmation message to the user
249
+ Furthermore, the wallet can use the NatSpec user documentation to display a human-readable confirmation message to the user
195
250
whenever they interact with the contract, together with requesting
196
251
authorization for the transaction signature.
197
252
0 commit comments