0

i wrote this code but i am confuse how to make a test script for it. because how do i input an array into the parameter? when i try to run the test script it says undeclared identifier names, uris, description

smart contract code:

function batchMintUniqueNFT(
        string[] memory _names,
        string[] memory _descriptions,
        string[] memory _images
    ) external onlyOwner{
        if(_names.length != _descriptions.length  
            _descriptions.length != _images.length 
            _images.length != _names.length
        ){
            revert UnbalancedMetadataLength(_names.length, _descriptions.length, _images.length);
        }

        uint256 amount = _names.length;
        if(amount == 0){
            revert InsuficientAmount(amount);
        }

        uint256 startTokenID = _nextTokenId();
        _mint(msg.sender, amount);
        for(uint256 i = 0; i < amount; i++){
            uint256 tokenID = startTokenID + i;
            string memory metadata = GenerateMetadata(_names[i], _descriptions[i], _images[i]);
            tokenURIs[tokenID] = metadata;

            emit MintingSuccess(msg.sender, tokenID, metadata);
        }
        successMinted += amount;
    }

i tried to test with this it fail:

function testbatchmintunique() external {
        string ;
        string ;
        string ;

        names[0] = "keren 1"; descriptions[0] = "deskripsi 1"; uris[0] = "https://ipfs.io/ipfs/bafkreihqaswfkli5plhmicnmqq6zqgci32tk26jxk7lix42ktkowc62cha";
        names[1] = "keren 2"; descriptions[1] = "deskripsi 2"; uris[1] = "https://ipfs.io/ipfs/bafkreihqaswfkli5plhmicnmqq6zqgci32tk26jxk7lix42ktkowc62cha";
        names[2] = "keren 3"; descriptions[2] = "deskripsi 3"; uris[2] = "https://ipfs.io/ipfs/bafkreihqaswfkli5plhmicnmqq6zqgci32tk26jxk7lix42ktkowc62cha";
        names[3] = "keren 4"; descriptions[3] = "deskripsi 4"; uris[3] = "https://ipfs.io/ipfs/bafkreihqaswfkli5plhmicnmqq6zqgci32tk26jxk7lix42ktkowc62cha";
        names[4] = "keren 5"; descriptions[4] = "deskripsi 5"; uris[4] = "https://ipfs.io/ipfs/bafkreihqaswfkli5plhmicnmqq6zqgci32tk26jxk7lix42ktkowc62cha";
        names[5] = "keren 6"; descriptions[5] = "deskripsi 6"; uris[5] = "https://ipfs.io/ipfs/bafkreihqaswfkli5plhmicnmqq6zqgci32tk26jxk7lix42ktkowc62cha";
        names[6] = "keren 7"; descriptions[6] = "deskripsi 7"; uris[6] = "https://ipfs.io/ipfs/bafkreihqaswfkli5plhmicnmqq6zqgci32tk26jxk7lix42ktkowc62cha";
        names[7] = "keren 8"; descriptions[7] = "deskripsi 8"; uris[7] = "https://ipfs.io/ipfs/bafkreihqaswfkli5plhmicnmqq6zqgci32tk26jxk7lix42ktkowc62cha";
        names[8] = "keren 9"; descriptions[8] = "deskripsi 9"; uris[8] = "https://ipfs.io/ipfs/bafkreihqaswfkli5plhmicnmqq6zqgci32tk26jxk7lix42ktkowc62cha";
        names[9] = "keren 10"; descriptions[9] = "deskripsi 10"; uris[9] = "https://ipfs.io/ipfs/bafkreihqaswfkli5plhmicnmqq6zqgci32tk26jxk7lix42ktkowc62cha";

        ketewelnft.batchMintUniqueNFT(names, descriptions, uris);
    }

1 Answer 1

1

I think you simply forgot the declaration in the beginning of the test:

function testbatchmintunique() external {
    string[10] memory names;
    string[10] memory descriptions;
    string[10] memory uris;

    ...
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.