structure in solidity solidity struct

The solution for “structure in solidity solidity struct” can be found here. The following code will assist you in solving the problem.

contract MyStructs {

struct NFT {
string name;
uint256 dna;
}
//creating nftList of array of strct NFT
NFT[] public nftList;

function addNFT(string memory _name, uint256 _dna) public {
// NFT memory newNFT;
// newNFT.name = _name;
// newNFT.dna = _dna;
NFT memory newNFT = NFT(_name, _dna);
nftList.push(newNFT);
}struct StructName {
uint8 text1,
uint32 text2,
uint8[3] textlist
}

StructName MyStruct = StructName(10, 300, [5, 7, 8])

// MyStruct.text1 => 10
// MyStruct.text2 => 300
// MyStruct.textlist => [5, 7, 8]

Thank you for using DeclareCode; We hope you were able to resolve the issue.

More questions on [categories-list]

Similar Posts