You are viewing a single comment's thread from:

RE: Solidity开发指南

in #starnotelast month

calldata调用
EVM的函数选择原理

Low level interactions 一般是调用receive() 或 fallback()
Low level interactions are used to send funds or calldata or funds & calldata to a contract through the receive() or fallback() function. Typically, you should only need to implement the fallback function if you are following an upgrade or proxy pattern.

The low level interactions section is below the functions in each deployed contract.

//calldata计算的三种方法
a. bytes32 calldata = abi.encodeWithSignature("transfer(address,uint256)", SomeAddress, 123)
  addr.call(calldata)
  addr.call{value: msg.value, gas: 5000}(calldata) 

b. abi.encodeWithSelector(IERC20.transfer.selector, to, amount);
c. abi.encodeCall(IERC20.transfer, (to, amount));