so this provider: new HDWalletProvider(privateKey, config.child.rpc)
cannot be used in client browser because I need to replace that with a signature provider, I haven’t success.
for init contract I usually replace it with hooks by:
const { account, chainId, library } = useWeb3React() library?.getSigner(account)
then I’m able to use in my contract. but now i’m struggling to use matic.js, i have no idea how to properly use it on client-browser because matic.js only give example using node.js with HDWallet/direct private-key.
so after I initialize matic.js
const posClient = async () => { const posClientx = new POSClient() return posClientx.init({ network: "testnet", version: "mumbai", log: true, child: { provider: library?.getSigner(account), defaultConfig: { from: account, }, }, parent: { provider: library?.getSigner(account), defaultConfig: { from: account, }, }, }) }
then call it
const client = await posClient() console.log(client, "client") const erc721Token = client.erc721( "0x94f1e509eb86201313557463d0d7a1f8f9d2d2fa", true ) console.log(erc721Token, "erc721Token") const result = await erc721Token.approveAll() const txHash = await result.getTransactionHash() console.log("txHash", txHash) const receipt = await result.getReceipt() console.log("receipt", receipt)
I’m not able to receive pop up metamask, if it’s on node.js (using private-key) will do transaction right away, please enlight me what do i do wrong?