这个问题其实是如何在 Solidity 中实现,调用合约的时候发送ETH .
只要在调用函数时, 附加{value: 1eth}
, 示例代码:
contract contractA {
function blah(int x, int y) payable {}
}
contract contractB {
function invokeContractA() {
contractA a = contractA(0x1234567891234567891234567891234567891234);
uint ValueToSend = 1234;
a.blah{value: ValueToSend}(2, 3);
}
}
参考文档, 外部函数调用: https://learnblockchain.cn/docs/solidity/control-structures.html?highlight=value#external-function-calls