Skip to content

Instantly share code, notes, and snippets.

@marekkirejczyk
Created October 19, 2018 14:40
Show Gist options
  • Save marekkirejczyk/eabbb387bacef7c1a69239c7a67e9402 to your computer and use it in GitHub Desktop.
Save marekkirejczyk/eabbb387bacef7c1a69239c7a67e9402 to your computer and use it in GitHub Desktop.
ERC1077 - draft 0.01
pragma solidity ^0.4.24;
contract IERC1077 {
enum OperationType {CALL, DELEGATECALL, CREATE}
event ExecutedSigned(bytes32 executionId, address from, uint nonce, bool success);
function lastNonce() public view returns (uint nonce);
function canExecute(
address to,
uint256 value,
bytes data,
uint nonce,
uint gasPrice,
address gasToken,
uint gasLimit,
OperationType operationType,
bytes extraData,
bytes signatures) public view returns (bool);
function executeSigned(
address to,
uint256 value,
bytes data,
uint nonce,
uint gasPrice,
address gasToken,
uint gasLimit,
OperationType operationType,
bytes extraData,
bytes signatures) public returns (bytes32);
}
@marekkirejczyk
Copy link
Author

marekkirejczyk commented Oct 19, 2018

Hash calculation:

    function calculateMessageHash(
        address from,
        address to,
        uint256 value,
        bytes data,
        uint nonce,
        uint gasPrice,
        address gasToken,
        uint gasLimit,
        OperationType operationType,
        bytes extraData) public pure returns (bytes32)
    {
        return keccak256(
            abi.encodePacked(
                from,
                to,
                value,
                keccak256(data),
                nonce,
                gasPrice,
                gasToken,
                gasLimit,
                uint(operationType),
                keccak256(extraData)
        ));
    }

For identity example call would look like this:

calculateMessageHash(this, to, value, data, nonce, gasPrice, gasToken, gasLimit, operationType, extraData)

For generic relayer contract:

calculateMessageHash(key, to, value, data, nonce, gasPrice, gasToken, gasLimit, operationType, extraData)

@radek1st
Copy link

Hi Marek, I can see that you are planning to be using only one nonce for everybody: lastNonce. We've identified it as a concurrency bottleneck, so are keeping the nonces separately per account: https://github.com/Tenzorum/personal-wallet-contracts/blob/master/contracts/PersonalWallet.sol#L24 which allows more parallelism.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment