delete
delete

Reputation: 19148

How to initialize an empty byte array in Solidity?

I need to pass an empty byte array to a function derived from OpenZeppelin:

function mintTo(address to, uint256 tokenId, uint256 amount) 
{
    bytes memory data;
    _mint(to, tokenId, amount, data);
}

However, although this code compiles and works perfectly, Slither is complaining that this is

is a local variable never initialized

I'm curious how to achieve that?

Upvotes: 0

Views: 674

Answers (1)

alephao
alephao

Reputation: 1273

You can shut slither up or just use an empty string:

_mint(to, tokenId, amount, "");

Upvotes: 1

Related Questions