Solidity學習疑問總結

木木的奇奇發表於2024-10-04

1位元組(Byte)=8位(bit)

建立物件?

    struct People {
        string name;
        uint age;
    }
    People public person = People({name:'ljq',age:12});

建立陣列?

contract SimpleStorage {
    uint256 num;
    struct People {
        string name;
        uint age;
    }
    People[] public PeopleList;
    function addPerson(string memory name, uint256 age ) public {
        People memory newPerson = People({name:name,age:age});
        PeopleList.push(People({name:'qq',age:13}));
    }
}