const main = async () =>{
    const abi = fs.readFileSync('erc20_abi.json', 'utf-8')
    const contract = new web3.eth.Contract(JSON.parse(abi), contractAddress);
    const transfer = contract.methods.transfer("0xDd63848C3A3582702B56c977480C12CCb14c6A0A", web3.utils.toHex(10e18));
    const encodedABI = transfer.encodeABI();

    const rawTransaction = {
        from: senderAddress,
        to: contractAddress,
        gas: 2000000,
        data: encodedABI
    const privKey = Buffer.from(privateKey, 'hex');

    const customChainParams = { name: 'matic-mumbai', chainId: 80001, networkId: 80001 }
    const common = Common.default.forCustomChain('goerli',customChainParams)

    const tx = new Tx(rawTransaction, {common });
    const serializedTx = tx.serialize();

    const receipt = await web3.eth.sendSignedTransaction('0x' + serializedTx.toString('hex'));

I am getting an error Method called with neither a hardfork set nor provided by param. Can someone please assist as to what I am doing wrong here.


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.