Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

sending a transaction requires a signer

I have an NFT Contract and i need to mint nft also i have a second contract
for handle buy and sell nft into this contract .

i using the ethers library .

this is my code for config :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

static async Initial(): Promise<any> {

    let provider = new ethers.providers.JsonRpcProvider(config.contractConfig.url);
    const signer = provider.getSigner();
    
    this.tokenContract = new ethers.Contract(config.contractConfig.nftAddress, NFT.abi, provider);
    this.dNFT = new ethers.Contract(config.contractConfig.dortajNftAddress, DNFT.abi, signer);

}

config address :

  export default {
     nftAddress: '0x444F15B115ED9663DAE46786a34AA3F6E8c0B57D',
     dortajNftAddress: '0x8e4bE2a3BD1169596c38952D8e837b20D419Bcd1',
     url : 'HTTP://127.0.0.1:7545'
   }

now i need to use this function for mint nft :

        let transaction = await this.tokenContract.mintToken();
        const tx = await transaction.wait();

but it show me this error ;

Error: sending a transaction requires a signer (operation="sendTransaction", code=UNSUPPORTED_OPERATION, version=contracts/5.5.0)

how can i solve this problem ?

>Solution :

In this line

this.tokenContract = new ethers.Contract(config.contractConfig.nftAddress, NFT.abi, provider);

try to pass signer instead of provider.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading