Skip to content

Support encoding constructor arguments #112

Open
@kamikazechaser

Description

@kamikazechaser

The ABI parser expects any function to be named. In some cases it would be useful to encode constructor args. (address) for example doesn't work. One way would be to reserve the constructor keyword in the lexer.

constructorFunc, err := w3.NewFunc("constructor(address)", "")
if err != nil {
	return nil, err
}

constructorArgs := []any{w3.A(0x765DE816845861e75A25fCA122bb6898B8B1282a)}

constructorBytecode, err := constructorFunc.EncodeArgs(constructorArgs...)
if err != nil {
	return nil, err
}

// Should return bytearray representing 000000000000000000000000765de816845861e75a25fca122bb6898b8b1282a

Not sure if this is within scope of w3 or should the abi package (abi.Pack) from geth be used instead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions