我正试图创建一个安全和退出与智能合同的互动。我成功地创建了一个新的安全机制,但是当我试图调用execTransaction函数时,我遇到了一些问题。
// SPDX-License-Identifier: MIT
pragma solidity >0.6.0;
import "./GnosisSafeProxyFactory.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "./GnosisSafe.sol";
interface GnosisSafeSetup {
function setup(
address[] calldata _owners,
uint256 _threshold,
address to,
bytes calldata data,
address fallbackHandler,
address paymentToken,
uint256 payment,
address payable paymentReceiver
) external;
}
contract CreateSafe {
GnosisSafeProxyFactory private constant factory = GnosisSafeProxyFactory(0xa6B71E26C5e0845f74c812102Ca7114b6a896AB2);
GnosisSafeProxy public proxy;
address singleton = 0xd9Db270c1B5E3Bd161E8c8503c55cEABeE709552;
address fallbackHandler = 0xf48f2B2d2a534e402487b3ee7C18c33Aec0Fe5e4;
address paymentReceiver = 0xe92Abac47DF8E48E5E60d5Ec9e348E9580191C93;
function createNewSafe() public {
address[] memory owners = new address[](1);
owners[0] = msg.sender;
bytes memory proxyInitData = abi.encodeWithSelector(
GnosisSafeSetup.setup.selector,
owners,
1, // threshold
address(0x0), // to
new bytes(0), // data
fallbackHandler,
address(0x0), // paymentToken
0, // payment
paymentReceiver
);
// safe address
proxy = factory.createProxyWithNonce(singleton, proxyInitData, block.timestamp);
}
function withdrawETH(address payable safeAddress, uint256 _value) public {
// TODO require balance > _value
GnosisSafe safe = GnosisSafe(safeAddress);
safe.execTransaction{value: _value}(
msg.sender, // to
_value,
new bytes(0), // data
0, // operation
0, // safeTxGas
0, // baseGas
0, // gasPrice
address(0), // gasToken
payable(msg.sender), // refundReceiver
"SIGNATURE" // copied from old transaction
);
}
}
TypeError:函数调用中参数的无效类型。请求从int_const 0到枚举Enum.Operation的隐式转换无效。
我看到的所有例子都使用0,我看到的是一个事务,其中我从保险箱中提取ETH,值也是0。还有人知道如何得到签名散列吗?
发布于 2022-04-05 09:17:17
在使用Enum.Operation
时,需要使用Solidity
。0
用于Javascript
示例。
https://ethereum.stackexchange.com/questions/125465
复制相似问题