gochain / web3

A CLI tool to interact with web3 blockchains - Ethereum, GoChain, etc
https://gochain.io
Apache License 2.0
405 stars 88 forks source link

invalid hex address on empty input array #294

Open ypcat opened 1 month ago

ypcat commented 1 month ago

Hi,

I found when calling contract from cli with empty array input would cause this error:

ERROR: Error calling constant function: invalid hex address:

I think the root cause should be that strings.Split on empty string results in a slice with one empty string ([""]) instead of 0-length ([]).

https://github.com/gochain/web3/blob/c84726a6a7ac1fc9579184bc6fe6e3297ef4c9fe/web3.go#L462-L469

I can submit a PR if needed.

Thanks.

treeder commented 1 month ago

PR welcome.

ypcat commented 1 month ago

Sent PR at https://github.com/gochain/web3/pull/295