Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Generalized Multicall Capabilities #6

Open
bonedaddy opened this issue Feb 13, 2021 · 1 comment
Open

Add Generalized Multicall Capabilities #6

bonedaddy opened this issue Feb 13, 2021 · 1 comment

Comments

@bonedaddy
Copy link
Contributor

At the moment I'm using a customized mutlicall contract that exposes view functions for specific functionality. This was due to the complexity of manual abi encoding/decoding with Golang. It is satisfactory, however there is something to be said for having a generalized golang equivalent of multicall.js.

@bonedaddy
Copy link
Contributor Author

One of the Go-Ethereum devs gave me this code snippet which can be refactored for a Golang equivalent of the Solidity abi.encode function:

// encodeState encodes the state as with abi.encode() in the smart contracts.
func encodeState(state *adjudicator.ChannelState) ([]byte, error) {
    args := abi.Arguments{
        {Type: abiBytes32},
        {Type: abiUint64},
        {Type: abiBytes},
        {Type: abiBytes},
        {Type: abiBool},
    }
    alloc, err := encodeAllocation(&state.Outcome)
    if err != nil {
        return nil, err
    }
    enc, err := args.Pack(
        state.ChannelID,
        state.Version,
        alloc,
        state.AppData,
        state.IsFinal,
    )
    return enc, errors.WithStack(err)
}

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

No branches or pull requests

1 participant