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

Document support in v1.3.2 for large JSON numbers #1577

Merged
merged 4 commits into from
Sep 13, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 46 additions & 2 deletions doc-site/docs/reference/types/_includes/ffbigint_description.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,49 @@ strings (with base 10).
On input you can provide JSON string (string with an `0x` prefix are
parsed at base 16), or a JSON number.

Be careful when using JSON numbers, that the largest
number that is safe to transfer using a JSON number is 2^53 - 1.
## Maximum size of numbers in versions of FireFly up to `v1.3.1`

In versions of FireFly up to and including `v1.3.1`, be careful when using large JSON numbers. The largest number that is safe to transfer using a JSON number is 2^53 - 1 and it is
possible to receive errors from the transaction manager, or for precision to be silently lost when passing numeric parameters larger than that. It is recommended to pass large numbers as strings to avoid loss of precision.

## Maximum size of numbers in versions of FireFly `v1.3.2` and higher

In FireFly `v1.3.2` support was added for 256-bit precision JSON numbers. Some application frameworks automatically serialize large JSON numbers to a string which FireFly already supports, but there is no upper limit
to the size of a number that can be represented in JSON. FireFly now supports much larger JSON numbers, up to 256-bit precision. For example the following input parameter to a contract constructor is now supported:

```
...
"definition": [{
"inputs": [
{
"internalType":" uint256",
"name": "x",
"type": "uint256"
}
],
"outputs":[],
"type":"constructor"
}],
"params": [ 10000000000000000000000000 ]
...
```

Some application frameworks seralize large numbers in scientific notation e.g. `1e+25`. FireFly `v1.3.2` added supported for handling scientific numbers in parameters. This removes the need to change an application
that uses this number format. For example the following input parameter to a contract constructor is now supported:

```
...
"definition": [{
"inputs": [
{
"internalType":" uint256",
"name": "x",
"type": "uint256"
}
],
"outputs":[],
"type":"constructor"
}],
"params": [ 1e+25 ]
...
```
Loading