0

Assuming I would have to store Monero addresses or any cryptonote based coins addresses in a smart contract, would there be any issues?

Consider that those addresses are as long as this random monero address:

43ZmqBKrvcL7nRYfTTrpngJ8M9bB6HyuvVnQzqJJW5Gai1ScVVDeSy5jDkKtt7qgB1Ld4Fx3MHEw1HkwZNPVkpmN7rhk9YT

The following smart contract stores the above address, however are there any drawbacks such as potential cybersecurity issues? Also could that smart contract be improved to be more efficient by storing the monero address as bytes rather than string??

pragma solidity ^0.5.1;


contract Addresses
{

string public moneroAddress;

function setAddress(string address_)public returns(bool)
{ 
moneroAddress = address_;
}
}
1

The address you provided is 95 characters long. That means 190 bytes. That will not fit in any byte arrays Solidity supports. Your only options for storing it are either a string or bytes (dynamically-sized arrays, see https://solidity.readthedocs.io/en/v0.5.3/types.html#arrays for more details). But there are no efficiency improvements between those two options - they are essentially the same thing.

Your contract stores the address as it is - no extra padding of characters or anything like that. There are no security problems with storing it like that. Except of course if you'd like to keep the address secret as everything is public in Ethereum.

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.