Questions tagged [web3js]

Javascript API and library for Ethereum To develop applications on Ethereum, you can use the web3 object provided by the web3.js library. Under the hood it communicates to a local node through RPC calls. web3.js works with any Ethereum node, which exposes an RPC layer. https://github.com/ethereum/wiki/wiki/JavaScript-API

Filter by
Sorted by
Tagged with
0 votes
0 answers
24 views

Contract not passing to front end

I am building a chat DApp. I have a smart contract and a mostly complete nextjs front end. My contract is deploying properly however, whenever I call my contract from the front end it doesn't work. My ...
user avatar
0 votes
0 answers
14 views

Chaining/Sequencing 2 or 3 transactions together

I'm trying to tackle a malicious siphon on an address whose privatekey was leaked, and the attacker's siphon keeps automatically detecting inputs, then instantly transfers out, leaving the address ...
user avatar
0 votes
1 answer
37 views

how do i get token balance and send token on BEP20?

Hi i have came out my code but i am not sure i am anywhere near what i am trying to achieve is Getting the balance of token of Token eg(BNB) Sending token after connected to metamask to another ...
user avatar
0 votes
1 answer
36 views

How to return an array when calling a solidity function?

Yo I'm pretty new to coding so bear with me. I'm using ReactJS with web3 to call functions from a smart contract but the function I'm trying to call returns an array and I can't figure out how to ...
user avatar
  • 3
0 votes
1 answer
22 views

Gnosis-safe - Get all owners of Gnosis-safe

I have created a Gnosis-safe. In general I wonder, how I can interact contractually (using web3) with the Gnosis-safe contract. The Gnosis-safe address links to a proxy contract. My question is how I ...
user avatar
  • 309
0 votes
0 answers
11 views

Getting `422` api error while executing a transaction using gnosis safe sdk

I have implemented the sdk for signing and sending custom tokens to other users from the gnosis treasury wallet. However, I am receiving the 422 api transaction error. Currently I am getting the ...
user avatar
0 votes
0 answers
20 views

Pete's Pet Shop error: Contract has not been deployed to detected network (network/artifact mismatch)

I followed Pete's Pet Shop tutorial at website: https://trufflesuite.com/tutorial/ However when I run npm run dev I get this error on the console window. Where did I go wrong? I double checked the ...
user avatar
1 vote
1 answer
236 views

MetaMask - RPC Error: The requested account and/or method has not been authorized by the user

I'm following the tutorial on https://www.toptal.com/ethereum/one-click-login-flows-a-metamask-tutorial#how-the-login-flow-works. One of the sections shows an example of prompting the metamask for us ...
user avatar
1 vote
1 answer
26 views

How to find a pancake pair creation date using web3 library?

For eg, in the PancakePair of CAKE/WBNB, the creator's address and transaction hash of the contact creation (which contains the timestamp of the pair's creation) can be found on the top right of this ...
user avatar
0 votes
0 answers
16 views

Signed raw transaction displays incorrect sender address

I have a transaction which I sign and broadcast later. If i try to broadcast the signed TX the sender address is incorrect. If i recover the address from the signature it is of course the correct one ...
user avatar
0 votes
1 answer
20 views

web3.eth.abi.encodeFunctionCall does not accept string as ABI parameter

I do not have the json interface as ABI, how can I construct the calldata? This does not work because encodeFunctionCall does not accept string as method signature: web3.eth.abi.encodeFunctionCall('...
user avatar
  • 169
0 votes
0 answers
28 views

How to increase an account nonce on web3js?

i'm running a script using web3js in which one i have my accounts[0] that is running 2 transactions. When i do: await web3.eth.getTransactionCount(accounts[0]) , i receive X (number) as a response. ...
user avatar
0 votes
0 answers
29 views

RPC Error: Invalid parameters: must provide an Ethereum address

I'll realy appreciate if someone will help me with this problem. I'm currently trying to create an application where users are able to transfer a custom ERC20 token from one metamask wallet to enother ...
user avatar
  • 1
0 votes
1 answer
18 views

Solidity - What will happen if multiple parents are inheriting OwnableUpgradeable?

I am not familiar with Solidity inheritance. Will there be multiple _owner variables defined when the Core is inheriting multiple parents that are both inheriting OwnableUpgradeable? Which one will be ...
user avatar
  • 101
0 votes
0 answers
32 views

Let client-side sign transaction and server-side broadcast tx

I am trying to let an user sign a transaction and broadcast that at a later moment with the client-side. I am aware it is unsafe but it is for internal use only. I currently have this code and get the ...
user avatar
0 votes
1 answer
42 views

Can we sign and send transaction through Metamask on behalf of backend (nodeJs)

I am building an application where I want to sign and send transaction through metamask prompt. Means as we sign and send transactions through web3 library in nodeJs so what will be the equivalent ...
user avatar
0 votes
0 answers
21 views

How to sign an ethereumjs-tx transaction client side

I have a function here that is supposed to sign a transaction and broadcast it after. With ethereumjs-tx you store the private key client-side injecting it into a buffer. Is it possible to let a ...
user avatar
0 votes
0 answers
48 views

Is it possible to send transaction in Polygon-mumbai using web3 and ethereumjs-tx?

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....
user avatar
0 votes
1 answer
17 views

How to call internal _burn function in smart contract since burnFrom and burn both are internal functions

We started to work on smart contract project on BEP20 tokens and we deployed a smart contract , now one of my customer wants to burn some tokens but in our contract i saw that _burn and _burnFrom both ...
user avatar
0 votes
1 answer
71 views

Autoburn NFT's after certain amount of time

how to create functionality to make NFT burn automatically when its expiry date is reached ? while minting i am storing 2 parameters minted date and number of months to expire , so i want it to burn ...
user avatar
0 votes
0 answers
27 views

Failing to sign a transaction using eth_sign

async function sendEth() { const txData = { gasLimit: web3.utils.toHex(25000), gasPrice: web3.utils.toHex(25e9), // 25 Gwei from: web3.currentProvider.selectedAddress, ...
user avatar
1 vote
1 answer
69 views

Is it possible to track how many event listener does the specific smart contract have?

I'm wondering if the above question is possible in ethers or web3? If yes, is it possible to get their IP as well? Thanks!
user avatar
0 votes
1 answer
23 views

Error: No events were emitted

I am coding an ICO project. However when trying to make the token purchase I got the following error: Using network 'test'. Compiling your contracts... =========================== > Compiling .\...
user avatar
0 votes
1 answer
26 views

How to send a specific token from a wallet when there are multiple tokens

I have two ERC20 tokens in my Metamask wallet, say TOKEN_1 and TOKEN_2. How do I send TOKEN_1 programmatically to another wallet?
user avatar
1 vote
0 answers
36 views

How to get the current smart contract size in KB using web3 tool

Suppose I deployed a smart contract on the Ethereum blockchain...and later added some storage data to the contract. I want to know the current contract size in KB programmatically from my web3 backend ...
user avatar
  • 163
0 votes
0 answers
12 views

How can I obtain the market cap from a coin via bitquery? (BNB, BUSD, PanCake,...)

It's my first job (I'm working for a friend) and first time with JS, so graphql is a bit hard for me, any help would be appreciated. I need to get the market cap from some coins via graphql The code ...
user avatar
  • 1
0 votes
1 answer
22 views

How can I customize my nft collection with the smart contract?

I want to add a logo and banner image on my nft collection. What I want to do is to add the logo and banner image when i deploy my contract so that no matter what the marketplace platform is I always ...
user avatar
0 votes
1 answer
27 views

Can we take the fees from seller and not buyer in 0x v4?

In v4 it was introduced that fees are paid by the buyer, denominated in the asset paid by the buyer, and are paid in addition to the erc20TokenAmount specified in the order. https://docs.0x.org/nft-...
user avatar
0 votes
1 answer
31 views

Exceeds block gas limit or base fee exceeds gas limit

I am learning web3, and a person is using solidity ^0.4.5, and I am adapting his code to solidity ^0.8.9, and I am facing this problem when if I have 1000 here: factory = await new web3.eth.Contract(...
user avatar
0 votes
0 answers
28 views

Access private/Internal functions of solidity [duplicate]

pragma solidity ^0.8.0; contract C { string internal secret= "secret data"; function x() internal returns (uint) { return 10; } } Accessing Internal Variable: web3.eth....
user avatar
  • 111
1 vote
1 answer
21 views

Can you make an NFT game based on a already released collection?

If a collection already exists out there and it’s smart contract has been deployed and everything, could one later then develop a game for that NFT collection and integrate the NFTs as a utility in ...
user avatar
  • 11
0 votes
1 answer
35 views

web3js getPastlog return empty array

i test web3js by geth,i build private net in local.i try to call getPastlog ,but return empty array. const Web3 = require("web3"); // const web3 = new Web3(new Web3.providers.HttpProvider(&...
user avatar
0 votes
0 answers
35 views

'Trans' cannot be used as a JSX component

I'm forking uniswap interface. Project is compiling to the point where we need to add liquidity(V2). Error `TypeScript error in /mnt/c/pr0/LP-frontend/src/components/AccountDetails/Copy.tsx(30,8): '...
user avatar
0 votes
0 answers
26 views

i need to intergrate walletconnect modal if user doesn't have wallet in mobile browser, leave your eth address after the answer 👍

i need to add wallet connect intergration if user opens this page in mobile browser and press connect wallet and without redirecting user to else if (web3) { initPayButton(); } else { window....
user avatar
0 votes
0 answers
25 views

convert a hex string to bytes32[] using web3js

I have a string thats 64 characters long and I need to convert it into a bytes32[] to be passed into a contract method call. How can I do it using web3js? I tried using hexToBytes in the utils package ...
user avatar
0 votes
0 answers
22 views

How to measure Gas consumption during a transaction?

I use geth network. I deployed a smart contract on the geth with a function. Then I sent several transactions with web3js. Now for my research paper, I need to calculate the amount of gas cost for 10 ...
user avatar
0 votes
1 answer
32 views

contract.methods ** is not a function using upgradeable contract and web3

On the BSC testnet I have created the following Proxy (upgradeable) contract: 0xe73585adad24f0994b794eb276561303e1f46a9a with a related implementation contract: ...
user avatar
0 votes
0 answers
48 views

How I can send entire ETH balance from one account to another with web3.py? <SOLVED>

sorry for being noob but I need little help. I'm trying to use web3 to transfer all of the balance of an account to another account. I read here on other topics that I need to subtract the Total ...
user avatar
0 votes
0 answers
11 views

Sign Message with Metamask In Pugjs Webpage

I have a NUXT app that involves signing a nonce with Metamask (NUXT is basically Vue with Server Side Rendering). This is the component where you sign a nonce to log in: handleSignMessage(...
user avatar
0 votes
1 answer
16 views

is there any way to import solidity codes with its deployed address ? or use an already deployed smart contract in my smart contract

I wanna call 3 functions of 3 different smart contracts which swap, buy and sell some ERC20/ERC721 tokens. all 3 functions are of 3 different smart contracts owned by 3 different websites. I wanna do ...
user avatar
0 votes
0 answers
69 views

how to decode from web3.eth.getTransactionReceipt logs

I use web3js and createAlchemyWeb3 library. I receive a transaction event in my log of my Ethereum transaction. id: 334 jsonrpc: "2.0" result: {blockHash: "...
user avatar
0 votes
1 answer
14 views

Why is my mint function adding an extra gwei to mints?

I have been testing out my NFT smart contract on Rinkeby to test out interaction on the front end. I have done many testnet mints with this same function, but the last two times that I have tried the ...
user avatar
0 votes
1 answer
19 views

My call to contract method not throw error but stuck, why?

when I call a contract method, which should revert and throw error: Contract souce code: pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "@...
user avatar
  • 172
0 votes
0 answers
7 views

Best way to update addresses in web3js subscription

I am using web3js to subscribe to logs for specific contracts. This list of contracts is pulled from a database. However, every once in a while this list will be updated. I am not sure of the best way ...
user avatar
0 votes
0 answers
12 views

Signing throws out scary warning

I am currently building a gambling website based on web3. Before the user can play slots etc... I need access to the funds so I created a signing message with which i can transfer funds. If he clicks ...
user avatar
  • 1
0 votes
0 answers
6 views

Smart Contract interaction with drizzle cacheCall() returning undefined

I have an existing contract and want to integrate drizzle to read data using drizzle cacheCall() I have setup my drizzle options as seen below (saw this method in drizzle doc) const options = { ...
user avatar
  • 11
1 vote
1 answer
35 views

SetApprovalForAll for multiple contracts in 1 txid

I was wondering if it was possible to set approval for multiple collections in 1 txid, rather then approving each collection individually.
user avatar
  • 11
0 votes
1 answer
64 views

Function to send Ether to a smart contract address

I have read a few similar question's but nothing with my exact question. I'm trying to make a function to send ether to the contract. But only the owner should be able to send ether to the contract. ...
user avatar
0 votes
0 answers
14 views

Ethers.js returning Unhandled Rejection (Error): 'args.method' must be a non-empty string

I am attempting to write a generic service for my smart contract function executions. For some reason that I cannot figure out the calling of this function is producing the error: Unhandled Rejection ...
user avatar
  • 1
0 votes
1 answer
13 views

Injected remix is using metamask's private key?

When I want to deploy smart contract by hardhat i need to put the private key ,is there any way to deploy smart contract like remix do in injectedweb3 (without using private key )? how remix can ...
user avatar