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();
  • 1
    You cannot use send without first unlocking your account on the node that you're connected to. And AFAIK, you cannot (or at least should not) do that when using a public node. So I suggest that you replace send with signing the transaction and then sending the signed transaction. – goodvibration Jun 30 '20 at 8:45
  • Thanks for the reply! I'll try doing the latter method you mentioned. – Vishnu Prakash Jun 30 '20 at 9:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.