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

"value" cannot be passed as a hex string on a SendTransaction request #223

Open
nguyer opened this issue Jun 15, 2022 · 3 comments
Open

Comments

@nguyer
Copy link
Contributor

nguyer commented Jun 15, 2022

If I have a smart contract function that is payable I need to set a value field in the JSON object of the request body for a SendTransaction request.

Today if I set this to a string like this:

{
  "value": "0x01"
}

I get the following result in the FireFly explorer:

{
	"id": "default:25a46a6d-961a-47e2-a7e0-5e3aaeb431f3",
	"message": "json: invalid number literal, trying to unmarshal \"\\\"0x01\\\"\" into Number",
	"success": false
}

I think some of the backslash escaping craziness there is actually just added by the UI.

Ethconnect logs the following:

[2022-06-15T12:57:33.507Z]  WARN Failed to process message MsgContext[SendTransaction/default:25a46a6d-961a-47e2-a7e0-5e3aaeb431f3]: json: invalid number literal, trying to unmarshal "\"0x01\"" into Number
@peterbroadhurst
Copy link
Contributor

That’s certainly the behaviour as designed today. That those inputs a base 10. The new FFTM connector toolkit is more permissive, using the utility helper FFBigInt from firefly-common.

A PR for an enhancement to also support base16 numbers in ethconnect would be cool.

@nguyer
Copy link
Contributor Author

nguyer commented Jun 15, 2022

It does let me pass value as a string though, as long as it is base 10, so I can still express large numbers which is good.

@peterbroadhurst
Copy link
Contributor

Yep - I think it uses the “json.Number” string type today

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