Call a contract method with the given signature. The signature is represented by a string consisting of the name of the method and a list of parameter types (e.g. `foo(uint256,uint256)`).
(
&mut self,
caller_address: H160,
contract_address: H160,
eth_amount: U256,
method_sig: &str,
method_args: &[u8],
)
| 190 | /// The signature is represented by a string consisting of the name of the method and |
| 191 | /// a list of parameter types (e.g. `foo(uint256,uint256)`). |
| 192 | pub fn call_function( |
| 193 | &mut self, |
| 194 | caller_address: H160, |
| 195 | contract_address: H160, |
| 196 | eth_amount: U256, |
| 197 | method_sig: &str, |
| 198 | method_args: &[u8], |
| 199 | ) -> (ExitReason, Vec<u8>) { |
| 200 | self.transact(|exec| { |
| 201 | let mut data = vec![]; |
| 202 | data.extend(derive_method_selector(method_sig)); |
| 203 | data.extend(method_args); |
| 204 | |
| 205 | let (exit_reason, buffer) = exec.transact_call( |
| 206 | caller_address, |
| 207 | contract_address, |
| 208 | eth_amount, |
| 209 | data, |
| 210 | u64::MAX, |
| 211 | vec![], |
| 212 | ); |
| 213 | |
| 214 | (exit_reason, buffer) |
| 215 | }) |
| 216 | } |
| 217 | |
| 218 | /// Execute custom EVM opecodes. |
| 219 | /// You are still required to specify a caller address and a contract address, even though a contract may not exist |