@@ -15,8 +15,8 @@ Hexadecimal Representations
1515* All hexadecimal values will be returned as text.
1616* All hexadecimal values will be ``0x `` prefixed.
1717
18- Addresses
19- ---------
18+ Ethereum Addresses
19+ ------------------
2020
2121All addresses must be supplied in one of three ways:
2222
@@ -41,3 +41,90 @@ prefix. It will also raise an error if the byte string or hex string is not
4141the exact number of bytes specified by the ABI type. See the
4242:ref: `enable-strict-byte-check ` section
4343for an example and more details.
44+
45+ Types by Example
46+ ----------------
47+
48+ Let's use a contrived contract to demonstrate input types in Web3.py:
49+
50+ .. code-block :: none
51+
52+ contract ManyTypes {
53+ // booleans
54+ bool public b;
55+
56+ // unsigned ints
57+ uint8 public u8;
58+ uint256 public u256;
59+ uint256[] public u256s;
60+
61+ // signed ints
62+ int8 public i8;
63+
64+ // addresses
65+ address public addr;
66+ address[] public addrs;
67+
68+ // bytes
69+ bytes1 public b1;
70+
71+ // structs
72+ struct S {
73+ address sa;
74+ bytes32 sb;
75+ }
76+ mapping(address => S) addrStructs;
77+
78+ function updateBool(bool x) public { b = x; }
79+ function updateUint8(uint8 x) public { u8 = x; }
80+ function updateUint256(uint256 x) public { u256 = x; }
81+ function updateUintArray(uint256[] memory x) public { u256s = x; }
82+ function updateInt8(int8 x) public { i8 = x; }
83+ function updateAddr(address x) public { addr = x; }
84+ function updateBytes1(bytes1 x) public { b1 = x; }
85+ function updateMapping(S memory x) public { addrStructs[x.sa] = x; }
86+ }
87+
88+ Booleans
89+ ________
90+
91+ .. code-block :: python
92+
93+ contract_instance.functions.updateBool(True ).transact()
94+
95+ Unsigned Integers
96+ _________________
97+
98+ .. code-block :: python
99+
100+ contract_instance.functions.updateUint8(255 ).transact()
101+ contract_instance.functions.updateUint256(2 ** 256 - 1 ).transact()
102+ contract_instance.functions.updateUintArray([1 , 2 , 3 ]).transact()
103+
104+ Signed Integers
105+ _______________
106+
107+ .. code-block :: python
108+
109+ contract_instance.functions.updateInt8(- 128 ).transact()
110+
111+ Addresses
112+ _________
113+
114+ .. code-block :: python
115+
116+ contract_instance.functions.updateAddr(" 0x0000000000000000000000000000000000000000" ).transact()
117+
118+ Bytes
119+ _____
120+
121+ .. code-block :: python
122+
123+ contract_instance.functions.updateBytes1(HexBytes(255 )).transact()
124+
125+ Structs
126+ _______
127+
128+ .. code-block :: python
129+
130+ contract_instance.functions.updateMapping({" sa" : " 0x0000000000000000000000000000000000000000" , " sb" : HexBytes(123 )}).transact()
0 commit comments