Reputation: 101
I have a very simple smart contract that stores data.
The data has already been binary encoded in Javascript,
const data: UInt8Array = await compress(customBinaryEncoder(userData));
With an array size of 2000, I end up with a ridiculous amount of gaz.
How to make the best usage of uint256 solidity?
const optimizeForUint256 = (data: UInt8Array): DataFormat => {}
const Uint256toUInt8 = (data: any): UInt8Array => {}
I will then edit the contract method to accept DataFormat
instead of uint8[]
.
function addPatches( uint8[] memory data) public returns (bool ok) {
require(userIds[msg.sender] > 0, "must Be registered");
uint64 id = userIds[msg.sender];
records[id].records.push(data);
ok = true;
return ok;
}
No need to decode the data in solidity, it is stored as is.
Upvotes: 0
Views: 17