小编Рус*_*ров的帖子

如何将代币发送到 0x 地址 - 燃烧代币?

我无法将burn方法添加到现有令牌中,因此我只有一种方法将令牌发送到0x0000000000000000000000000000000000000000,但我无法将令牌转移到0x地址。

当尝试通过合同发送时,我收到错误“收件人地址在 Metamask 和 Remix 中无效”,但我看到人们如何发送到该地址。

有什么办法可以做到这一点吗?

ethereum

4
推荐指数
1
解决办法
9605
查看次数

如何将struct从合约A传递到合约B?最佳实践

我发现这样,当创建一个具有结构的通用接口时,然后合约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)

structure solidity

3
推荐指数
1
解决办法
4576
查看次数

如何通过web3将地址类型转换为bytes32?

我有需要以bytes32输入的合同,所以我需要将地址转换为bytes32,但在web3中看不到这个方法。

ethereum solidity web3-donotuse

1
推荐指数
1
解决办法
1712
查看次数

merkletreejs 方法 getHexProof 不起作用?

我正在尝试使用 merkletreejs 库测试 merkle 证明,但我不明白为什么它有效

\n
const 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\n
Run Code Online (Sandbox Code Playgroud)\n

但这不是吗?

\n
const 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\n
Run Code Online (Sandbox Code Playgroud)\n

merkle-tree

1
推荐指数
1
解决办法
1581
查看次数