Cryptocurrency Ethereum Mastering Development

Error while calling a function,

I created a Factory Contract which can create new ERC20 tokens with the parameters passed to it.

Address of the contract: (Goerli Testnet)


I tested the contract on remix and it works fine. But when I’m calling this function using web3js. I’m getting this error:

(node:10286) UnhandledPromiseRejectionWarning: Error: Returned error: The method eth_sendTransaction does not exist/is not available

The function definition:

function createTokens(uint _initialSupply, string calldata _name, string calldata _symbol, string calldata artistName) external{
        require(msg.sender == owner,"Unauthorized Access");
        newContract = new ERC20(_initialSupply,_name,_symbol);
        artistToERC[artistName] = address(newContract);
        emit contractCreated(artistName,artistToERC[artistName]);

The function call I implemented:

    account = await web3.eth.accounts.privateKeyToAccount("3d1e49923912999811b49cde8862dc701d7493878ecd9c4e5937c5cb57444843", [ignoreLength = true]);
    var contract = new web3.eth.Contract(abi,contractAddress);
    let add = await contract.methods.owner().call();
    let peaches = await contract.methods.createTokens(2100000000,"Peaches Token","DAD","Peach Pit").send({from:account.address});
    let newaddress = await contract.methods.artistToERC("Peach Pit").call();

Leave a Reply

Your email address will not be published. Required fields are marked *