Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MetaMask - RPC Error: MetaMask Tx Signature: User denied transaction signature #434

Open
norbibi opened this issue Apr 20, 2024 · 0 comments

Comments

@norbibi
Copy link

norbibi commented Apr 20, 2024

Hi,

I'm unable to catch a transaction reject from Metamask.
I still get the Uncaught (in promise) error.

My code:

import { POSClient, use } from '@maticnetwork/maticjs';
import { Web3ClientPlugin } from '@maticnetwork/maticjs-web3';
import Web3 from "web3";

use(Web3ClientPlugin);

const posClient = new POSClient();
const web3 = new Web3(window.ethereum);
const GLMtokenAddress = "0x0B220b82F3eA3B7F6d9A1D8ab58930C064A2b5Bf";
const YagnaWalletAddress = "0x2a624D89C9C30A424eE07C9FF9442F03a1f208CF";
const erc20Token = posClient.erc20(GLMtokenAddress);

export async function pay_ticket(account, quantity) {
	var qtty = 600000000000000000 * quantity;
	return posClient.init({
        log: false,
        network: "mainnet",
        version: 'v1',
        parent: {
            provider: web3.currentProvider,
            defaultConfig: {
                from: account
            }
        },
        child: {
            provider: web3.currentProvider,
            defaultConfig: {
                from: account
            }
        }
    }).then(() => {
        return web3.eth.getGasPrice().then((fees) => {
        	return fees;
        });
    }).then((fees) => {
    	return erc20Token.transfer(qtty.toString(), YagnaWalletAddress, {gasPrice: fees*2}).then((tx) => {
    	    return tx;
    	});
    }).then((tx) => {
    	return tx.getReceipt().then((receipt) => {
            return {'err': null, 'txhash': receipt.transactionHash};
        });
    }).catch((err) => {
        return {'err': 'err', 'txhash': null};
    });
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant