CRYPTO NEWS

Return data using EVM memory within a callback function to Web3/Front-end

To my understanding, the standard for return values to the front-end/web3 is to subscribe to an event(s) emitted to the chain, though I wonder how one can return/retrieve the data in memory passed to a callback function without emitting it on storage?

I greatly appreciate any feedback or insight!

When to use .call and abi.encodeWithSignature when calling external function and when not to

Can anyone tell me why sometimes you have to us the .call method and abi.encodeWithSignature when you want to call a function on an an external contract (First example below) and other times you can simply call the contract name.function with the parameters (Second example below). Aside from the obvious difference than one is in::Listen

Can anyone tell me why sometimes you have to us the .call method and abi.encodeWithSignature when you want to call a function on an an external contract (First example below) and other times you can simply call the contract name.function with the parameters (Second example below).

Aside from the obvious difference than one is in the constructor and one is in a function I am assuming the 2nd method of calling does not have to use .call because we have imported the contract but if anyone can clarify when to use the different methods would be appreciated?

Contract using the .call method…

pragma solidity 0.8.13;  contract callerContract{     address payable targetAddress = payable(0x3328358128832A260C76A4141e19E2A943CD4B6D);      bytes public result;       constructor() payable{}          function callExternal(uint256 _number) public{         (bool success, bytes memory returnData) = targetAddress.call{value: 100, gas: 10000}(abi.encodeWithSignature("targetFunction(uint256)",_number));         result = returnData;     } } 

Contract that calls function with contract name.functionName with value and function parameters (No .call method and no abiEncodeWithSignature to access function needed here) I am referring to gateway.depositETH… etc..

pragma solidity ^0.7.5;  import "./IERC20.sol"; import "./IWETHGateway.sol";  contract Escrow {     address arbiter;     address depositor;     address beneficiary;      uint initialDeposit;               IWETHGateway gateway = IWETHGateway(0xDcD33426BA191383f1c9B431A342498fdac73488);     IERC20 aWETH = IERC20(0x030bA81f1c18d280636F32af80b9AAd02Cf0854e);      constructor(address _arbiter, address _beneficiary) payable {         arbiter = _arbiter;         beneficiary = _beneficiary;         depositor = msg.sender;         initialDeposit = msg.value;          gateway.depositETH{value: address(this).balance}(address(this), 0);              } 

Return data using EVM memory within a callback function to Web3/Front-end

Shopping cart
There are no products in the cart!
Continue shopping
0