Skip to content

Commit

Permalink
[Docs] Updated solidity example to modern syntax (#4147)
Browse files Browse the repository at this point in the history
* [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 <Juan.Alonso@trimble.com>

* Revert "[Docs] Fixed a broken link (#1)"

This reverts commit 0de1272.

Co-authored-by: Juan Alonso <Juan.Alonso@trimble.com>
  • Loading branch information
mongolsteppe and jual3 committed Jul 21, 2021
1 parent 33167fc commit 51bf795
Showing 1 changed file with 32 additions and 28 deletions.
60 changes: 32 additions & 28 deletions docs/glossary.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,47 +51,51 @@ Example

.. code-block:: javascript
pragma solidity ^0.8.4;
contract Test {
uint a;
address d = 0x12345678901234567890123456789012;
address d = 0xdCad3a6d3569DF655070DEd06cb7A1b2Ccd1D3AF;
function Test(uint testInt) { a = testInt;}
constructor(uint testInt) { a = testInt;}
event Event(uint indexed b, bytes32 c);
event Event2(uint indexed b, bytes32 c);
function foo(uint b, bytes32 c) returns(address) {
Event(b, c);
function foo(uint b, bytes32 c) public returns(address) {
emit Event(b, c);
return d;
}
}
// would result in the JSON:
[{
"type":"constructor",
"payable":false,
"stateMutability":"nonpayable"
"inputs":[{"name":"testInt","type":"uint256"}],
},{
"type":"function",
"name":"foo",
"constant":false,
"payable":false,
"stateMutability":"nonpayable",
"inputs":[{"name":"b","type":"uint256"}, {"name":"c","type":"bytes32"}],
"outputs":[{"name":"","type":"address"}]
},{
"type":"event",
"name":"Event",
"inputs":[{"indexed":true,"name":"b","type":"uint256"}, {"indexed":false,"name":"c","type":"bytes32"}],
"anonymous":false
},{
"type":"event",
"name":"Event2",
"inputs":[{"indexed":true,"name":"b","type":"uint256"},{"indexed":false,"name":"c","type":"bytes32"}],
"anonymous":false
}]
[
{
"type": "constructor"
"stateMutability": "nonpayable",
"inputs": [{"internalType":"uint256","name":"testInt","type":"uint256"}],
},
{
"type": "event"
"name": "Event",
"inputs": [{"indexed":true,"internalType":"uint256","name":"b","type":"uint256"},{"indexed":false,"internalType":"bytes32","name":"c","type":"bytes32"}],
"anonymous": false,
},
{
"type": "event"
"name": "Event2",
"inputs": [{"indexed":true,"internalType":"uint256","name":"b","type":"uint256"},{"indexed":false,"internalType":"bytes32","name":"c","type":"bytes32"}],
"anonymous": false,
},
{
"type": "function"
"name": "foo",
"stateMutability": "nonpayable",
"inputs": [{"internalType":"uint256","name":"b","type":"uint256"},{"internalType":"bytes32","name":"c","type":"bytes32"}],
"outputs": [{"internalType":"address","name":"","type":"address"}],
}
]
------------------------------------------------------------------------------

0 comments on commit 51bf795

Please sign in to comment.