Closed 0xCactus closed 2 years ago
You need serialize BN
as String
in JSON.stringify
and create a new BN
from String
in JSON.parse
.
You serialize
BN
asString
inJSON.stringify
and create a newBN
fromString
inJSON.parse
.
@fanatid JSON.parse converts it to an object of {"_bn":{"negative":0,"words":[22127744,7770787,46556922,61120705,33815569,32632618,19307227,5865125,41554856,1514719,0],"length":10,"red":null}}
without the BN class method. I tried passing the object into new BN(object)
but the BN created is off from the original BN
Applied
JSON.stringify
on BN which gave me"{"_bn":{"negative":0,"words":[22127744,7770787,46556922,61120705,33815569,32632618,19307227,5865125,41554856,1514719,0],"length":10,"red":null}}"
. Any idea how I may convert this back into an instance of BN?