Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

Commit 51bf795

Browse files
mongolsteppejual3
andauthored
[Docs] Updated solidity example to modern syntax (#4147)
* [Docs] Updated solidity example to modern syntax Replaced the old constructor function syntax with the modern one, added 'emit' to event calls, added pragma, added a valid bytes32 value and updated the JSON ABI. * [Docs] Fixed a broken link (#1) Original link gives out a 404, replaced by the proper guide. Co-authored-by: Juan Alonso <[email protected]> * Revert "[Docs] Fixed a broken link (#1)" This reverts commit 0de1272. Co-authored-by: Juan Alonso <[email protected]>
1 parent 33167fc commit 51bf795

File tree

1 file changed

+32
-28
lines changed

1 file changed

+32
-28
lines changed

docs/glossary.rst

+32-28
Original file line numberDiff line numberDiff line change
@@ -51,47 +51,51 @@ Example
5151

5252
.. code-block:: javascript
5353
54+
pragma solidity ^0.8.4;
5455
contract Test {
5556
uint a;
56-
address d = 0x12345678901234567890123456789012;
57+
address d = 0xdCad3a6d3569DF655070DEd06cb7A1b2Ccd1D3AF;
5758
58-
function Test(uint testInt) { a = testInt;}
59+
constructor(uint testInt) { a = testInt;}
5960
6061
event Event(uint indexed b, bytes32 c);
6162
6263
event Event2(uint indexed b, bytes32 c);
6364
64-
function foo(uint b, bytes32 c) returns(address) {
65-
Event(b, c);
65+
function foo(uint b, bytes32 c) public returns(address) {
66+
emit Event(b, c);
6667
return d;
6768
}
6869
}
6970
71+
7072
// would result in the JSON:
71-
[{
72-
"type":"constructor",
73-
"payable":false,
74-
"stateMutability":"nonpayable"
75-
"inputs":[{"name":"testInt","type":"uint256"}],
76-
},{
77-
"type":"function",
78-
"name":"foo",
79-
"constant":false,
80-
"payable":false,
81-
"stateMutability":"nonpayable",
82-
"inputs":[{"name":"b","type":"uint256"}, {"name":"c","type":"bytes32"}],
83-
"outputs":[{"name":"","type":"address"}]
84-
},{
85-
"type":"event",
86-
"name":"Event",
87-
"inputs":[{"indexed":true,"name":"b","type":"uint256"}, {"indexed":false,"name":"c","type":"bytes32"}],
88-
"anonymous":false
89-
},{
90-
"type":"event",
91-
"name":"Event2",
92-
"inputs":[{"indexed":true,"name":"b","type":"uint256"},{"indexed":false,"name":"c","type":"bytes32"}],
93-
"anonymous":false
94-
}]
73+
[
74+
{
75+
"type": "constructor"
76+
"stateMutability": "nonpayable",
77+
"inputs": [{"internalType":"uint256","name":"testInt","type":"uint256"}],
78+
},
79+
{
80+
"type": "event"
81+
"name": "Event",
82+
"inputs": [{"indexed":true,"internalType":"uint256","name":"b","type":"uint256"},{"indexed":false,"internalType":"bytes32","name":"c","type":"bytes32"}],
83+
"anonymous": false,
84+
},
85+
{
86+
"type": "event"
87+
"name": "Event2",
88+
"inputs": [{"indexed":true,"internalType":"uint256","name":"b","type":"uint256"},{"indexed":false,"internalType":"bytes32","name":"c","type":"bytes32"}],
89+
"anonymous": false,
90+
},
91+
{
92+
"type": "function"
93+
"name": "foo",
94+
"stateMutability": "nonpayable",
95+
"inputs": [{"internalType":"uint256","name":"b","type":"uint256"},{"internalType":"bytes32","name":"c","type":"bytes32"}],
96+
"outputs": [{"internalType":"address","name":"","type":"address"}],
97+
}
98+
]
9599
96100
97101
------------------------------------------------------------------------------

0 commit comments

Comments
 (0)