zeta-chain / protocol-contracts

Protocol contracts implementing the core logic of the protocol, deployed on ZetaChain and on connected chains
MIT License
71 stars 58 forks source link

Enable calling contracts on connected chains with caller info #344

Closed fadeev closed 2 months ago

fadeev commented 2 months ago

Right now, when a universal contract A on ZetaChain makes a gateway.call a contract B on a connected chain, contract B is executed without knowing contract A address.

This makes it virtually impossible to establish a connection for sending custom ERC-20s, NFTs and other valuables between ZetaChain and connected chains, because the message essentially comes without authentication.

The proposal is to allow universal contracts to make calls with original sender information passed as a parameter.

function onCall(
    messageContext calldata messageContext,
    bytes calldata message
) external override {}
struct messageContext {
    bytes origin;
    address sender; // not used
    uint256 chainID;
}

A simple solution could be to define this onCall interface, the onCall contains caller address, this value is authenticated, onCall is the only method that cannot be called through arbitrary call to prevent spoofing.