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

Encode abi params #39

Closed
tomasz90 opened this issue Apr 21, 2022 · 1 comment
Closed

Encode abi params #39

tomasz90 opened this issue Apr 21, 2022 · 1 comment

Comments

@tomasz90
Copy link

Hi again :)

Is there possibility to encode abi params without function name itself? My workaround is empting first 4 bytes for example:

val args = Tuple(Address.wrap("0x5757371414417b8C6CAad45bAeF941aBc7d3Ab32"), 5)
val f = Function("(address,uint8)")
val callData = f.encodeCall(args)

it gives: 0xd6ec702b0000000000000000000000005757371414417b8c6caad45baef941abc7d3ab320000000000000000000000000000000000000000000000000000000000000005
then I clear first bytes. I bet that this library have such functionality.

Thanks!

@esaulpaugh
Copy link
Owner

Yes if you have a TupleType reference you can call the encode method.

If you have a Function you can call getInputs to get the params TupleType

You can also use TupleType::parse or TypeFactory::create giving the signature of the params type.

For example passing the String "(int,bool,string)" would create a TupleType with three elements.

@esaulpaugh esaulpaugh pinned this issue Apr 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants