2

I'm signing a hash and getting a string with 130 bytes. What is the best way to store this signature later in my smart contract?

Should I just go ahead and split it into r,s, and v and store it in four byte32 vars and one byte2 var or should I use bytes? Or String? Which is cheaper?

2

The initial cost of storing it in a bytes is approximately 20% more than using 4x bytes32 and 1x bytes2.

You should also consider what your contract is going to do with the signature. If it's going to do some computation on the parts, you may not want the overhead of splitting the bytes into pieces again.

On the other hand, if you're only going to pass the signature around as a whole, using just one bytes variable will make the code a lot easier to read.

I hope this helps somewhat :-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.