array
,bytes
andstring
are treated as following way
// if there is uint256[] memory ids = new uint256[](3);
// ids[0] = 1;
// ids[1] = 2;
// ids[2] = 3;
0x0000000000000000000000000000000000000000000000000000000000000020 // 0x00 : where the array starts
0x0000000000000000000000000000000000000000000000000000000000000003 // 0x20 : length of 'ids'
0x0000000000000000000000000000000000000000000000000000000000000001 // 0x40 : ids 1st item
0x0000000000000000000000000000000000000000000000000000000000000002 // 0x80 : ids 2nd item
0x0000000000000000000000000000000000000000000000000000000000000003 // 0xa0 : ids 3rd item
- But in case of
bytes
andstring
are slightly different.
// if there is bytes memory txt = "abc";
0x0000000000000000000000000000000000000000000000000000000000000020 // 0x00 : where the string starts
0x0000000000000000000000000000000000000000000000000000000000000003 // 0x20 : length of 'txt'
0x6162630000000000000000000000000000000000000000000000000000000001 // 0x40 : there is "abc" which is 61 62 63 and it's left aligned
mapping
is a function. CheckbalanceOf
.
- Install Foundry
curl -L https://foundry.paradigm.xyz | bash
foundryup
-
Install solidity compiler https://docs.soliditylang.org/en/latest/installing-solidity.html#installing-the-solidity-compiler
-
Build Yul contracts and check tests pass
forge test
Run tests (compiles yul then fetch resulting bytecode in test)
forge test
To see the console logs during tests
forge test -vvv