我无法将burn方法添加到现有令牌中,因此我只有一种方法将令牌发送到0x0000000000000000000000000000000000000000,但我无法将令牌转移到0x地址。
当尝试通过合同发送时,我收到错误“收件人地址在 Metamask 和 Remix 中无效”,但我看到人们如何发送到该地址。
有什么办法可以做到这一点吗?
我发现这样,当创建一个具有结构的通用接口时,然后合约A和B继承该具有结构的接口。
但我想知道是否还有其他方法?
是否存在可以更新具有结构的合约的情况?
pragma experimental ABIEncoderV2;
pragma solidity ^0.6.0;
interface params {
struct structTest {
uint256 data;
}
}
contract contractA is params{
function testCall(structTest calldata _structParams) public pure returns (uint256){
return _structParams.data;
}
}
contract contractB is params{
contractA aContractInstance;
constructor (address _a) public {
aContractInstance = contractA(_a);
}
function test(structTest calldata _structParams) public view returns(uint256){
// call contract A from B and pass structure
return aContractInstance.testCall(_structParams);
}
}
Run Code Online (Sandbox Code Playgroud) 我有需要以bytes32输入的合同,所以我需要将地址转换为bytes32,但在web3中看不到这个方法。
我正在尝试使用 merkletreejs 库测试 merkle 证明,但我不明白为什么它有效
\nconst tree = new MerkleTree(leaves, SHA256)\nconst root = tree.getHexRoot()\nconst leaf = SHA256('a')\nconst proof = tree.getProof(leaf) // \xd0\xa0\xd0\x90\xd0\x91\xd0\x9e\xd0\xa2\xd0\x90\xd0\x95\xd0\xa2\nconsole.log(tree.verify(proof, leaf, root)) // true\nRun Code Online (Sandbox Code Playgroud)\n但这不是吗?
\nconst tree = new MerkleTree(leaves, SHA256)\nconst root = tree.getHexRoot()\nconst leaf = SHA256('a')\nconst proof = tree.getHexProof(leaf)\nconsole.log(tree.verify(proof, leaf, root)) // false\nRun Code Online (Sandbox Code Playgroud)\n