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
0answers
3 views

AttributeError: 'int' object has no attribute 'buildTransaction' - Python Web3 Solidity

I'm using this code to swap token USDT to token A but it has been stuck by this error: AttributeError: 'int' object has no attribute 'buildTransaction' Here is my code: path = [tokenA,tokenB] ...
0
votes
0answers
3 views

How would you get total transactions submitted by an address to a specific smart contract?

If I want to see how many transactions your address has sent to Opensea's contracts over the last year - how would you do this? Would you just query etherscan? Or is there a better way?
0
votes
0answers
7 views

Getting my estimated impernemant loss

I am using web3 lib for node js for the first time. I am trying to wrap my mind of how to get my impernament loss. I had in mind two ways and hoping you can help me. Use getReserves function at my ...
0
votes
1answer
9 views

web3.js, how to get list of accounts with one MNEMONIC(seed phrase)

pls someone save me from getting list of accounts(private keys) with MNEMONIC in web3.js, just like how it perfromed with metamask, just enter your MNEMONIC, then you could just add your way up to ...
0
votes
0answers
15 views

Which address is paying the gas fee? And, can the smart contract pay the gas fee by itself?

pragma solidity ^0.8.1; contract SendMoney{ uint public publicBalance; uint public lockedUntil; function receiveMoney() public payable{ publicBalance += msg.value; ...
0
votes
1answer
15 views

Web3py - Getting pending TX's?

Is there any way to get pending transaction for a specified address? I can get all pending transactions for current pending block but I can't filter them. I can do: txHashPending = w3.eth.filter('...
0
votes
0answers
7 views

Does opensea store the price of an nft item on the smart contract?

I was interacting with open-sea on the rinkeby testnet, After deploying some nfts, I listed the price for each of the item, While i was listing them I did not pay any gas fee but provide a signature. ...
0
votes
0answers
6 views

Why don't we have to import web3.js into testing js files?

As a newbie to solidity, this is my code for testing some smart contract that I wrote, by following a tutorial. The name of the file is "EthSwap.test.js" and I'm using "truffle". ...
0
votes
0answers
19 views

NFT minting and payment validation process

I am new to NFT dev scene and trying to sort out minting process. After I deploy ERC-721 contract to blockchain, in case of direct website purchase I mediate actual payment, verify that it has really ...
0
votes
0answers
6 views

I keep getting a random error when running truffle test

I have no idea why this happens My Code
0
votes
1answer
9 views

EthersJS JSON to sha256: Error string too long

what I'm trying to accomplish is creating a hash of a JSON object. This will then be used as a bytes32 parameter when minting a token. I thought the best way to go about this is to first stringify a ...
0
votes
0answers
13 views

Does a blockchain P2E game needs a back-end/database like NodeJS and MySql?

I'm diving into the P2E world and have some doubts about it, I know a basic game should have a front-end like React.JS and a back-end (smart contract, solidity), but does it also need a back-end like ...
0
votes
0answers
7 views

Recover Y-parity from DER-signature for EIP-1559

I have a software system where signing ETH transactions happens in a black box. I give the information required, and it returns to me a DER-signature (30|totalLen|02|lenR|R|02|lenS|S). Now I'm aware ...
0
votes
0answers
13 views

Signing a tuple (struct) for ECDSA.recover

I'm using web3js, and I'm trying to sign a tuple correctly. Below you can see the solidity code for verification. I'm using draft-EIP712Upgradeable.sol struct NFTVoucher { uint256 tokenId; ...
0
votes
0answers
7 views

How to Buy/Sell tokens using Uniswap V3 Multicall function?

I used to create programs to buy and sell tokens by interacting directly with Uniswap V2 router functions (SwapExactEthForTokens, and others). It was fairly simple because all I needed to do was to ...
1
vote
2answers
20 views

How to call internal _burn function of already deployed smart contract?

i have started to work on ethereum project. i have a customer who owns his own token and he wants to burn some tokens. i have seen that the smart contract has as an internal _burn function but this is ...
1
vote
3answers
28 views

Is there any way to write a smart contract function that can be callable only through DAPP?

I want to create a solidity function that will be external/public will be callable only through dapp and not from etherscan.io. Is there any way, like modifier or third-party?
0
votes
0answers
5 views

Should I replace public variable calls with event listeners?

I am writing a contract that has an array or entrants. Currently, in web3, when a user enters I call contract.methods.enter().send(..) and it updates this array. I then call contract.methods....
1
vote
1answer
20 views

When using web3.js/Metamask on your website - how can you trust the data coming from your users?

So let's say your user sends a transaction, your script gets the receipt (getTransactionReceipt), checks if everything is fine and then does something. Can't people just rewrite your scripts in ...
0
votes
0answers
7 views

How to check malicious code if it's safe to connect wallet to website?

The source code of this website doesn't show the contract address being interacted with when someone connects their Ethereum wallet to their site. Would like to check the underlying Solidity code of ...
0
votes
0answers
9 views

Ethers - Reading Staked Balance from Staking Contract

I'm trying to read the value of a given token that is staked or locked. I can get this to work for DuckStarter's staking contract in NodeJS using the EthersJS package like so: // THIS WORKS async ...
0
votes
0answers
6 views

Filter out mint and burn Transfers from Transfer events (web3.js)

In web.js Library Is there a way to filter out the Transfers events generated by the mint and burn function so as to ignore all the Transfer events generated by the mint or burn function. I know we ...
0
votes
1answer
20 views

How would I go about finding out whether an address owns a specific NFT or not?

Can it be done simply using web3.js? Can I do it on both ERC-721 and ERC-1155 NFTs?
1
vote
2answers
23 views

Web3 + React: After successful transacion, try to get changed state but returns old value?

I'm trying to do something pretty simple using React, but I can't understand what's going on. const A = await myContract.getA() // A = 0 myContract .setA(1) // should set A = 1 => ...
0
votes
1answer
17 views

Store PrivateKey in webapp to send in transaction

I have a big question regarding the security of my system. Well, what happens.. I developed my contract using ECDSA, that is, it is only possible to do actions in my contract if the transaction is ...
0
votes
0answers
11 views

Web3 related jobs

I am looking for job opportunities in the web3 space. May I know what are some areas/ websites where I can find such jobs? Would greatly appreciate some help here. Thanks!:)
0
votes
0answers
19 views

How to access different contracts with same name in Truffle

I deployed three contracts where the contract itself is same but the parameters are different. const Token = artifacts.require("Token"); module.exports = async function (deployer) { // ...
0
votes
0answers
9 views

Quick ways to learn web3.js please?

could you please suggest some way's to learn about web3.js quickly? I have gone through https://web3js.readthedocs.io/en/v1.5.2/ it is really good, but it is so long and difficult to memorize. It's ...
1
vote
1answer
26 views

Unable to connect to BSC testnet with web3.js

From this tutorial, I learned the RPC URL for BSC Testnet is https://data-seed-prebsc-1-s1.binance.org:8545, but when I use it with web3.js like: const web3 = new Web3('https://data-seed-prebsc-1-s1....
0
votes
0answers
11 views

Trying to use an Alchemy Websockets address to subscribe to an event but it errors out when it tries to update

Here is the script: const Big = require('big.js'); const blk = require('./blockchain'); const UniswapV2Pair = require('./abi/IUniswapV2Pair.json'); const cc = require('./common_code'); const ...
0
votes
1answer
12 views

How to decode event data "0x0000000000000000000000000000000000000000000000000000000000000002"

I got "0x0000000000000000000000000000000000000000000000000000000000000002" which is "id" from event in the code below. And, I want to decode "...
0
votes
0answers
8 views

gas vs gasLimit in web3.js [duplicate]

I've seen a bunch of stackoverflow posts on this and want to make sure I've got it right. I'm running into an issue where on test networks I can do this: contract.methods.mint(1).send({ from: ...
0
votes
0answers
13 views

Internal JSON-RPC error code -32602 invalid argument 0: hex string without 0x prefix on Binance Smart Chain Test Net

I'm building a web page using react and web3js to send transactions through meta-mask on Binance Smart Chain test net. The transactions goes through but about 20% of times, I get this error that ...
1
vote
1answer
17 views

Unable to construct hash from address and uint256 for ecrecover and signature verification

I am creating a signature with web3.js form a hashed message that contains two numbers and an address: const tokenIds = [1,2,3]; const state = 1; const messageHash = web3.utils.keccak256(tokenIds....
0
votes
0answers
14 views

Signing with BSC Provider causes unknown ENS error

I am not sure why this is throwing an error. From all the examples I've looked it up, it seems correct, but no amount of chaning how i send the provider makes the error go away. mintReward: function(...
0
votes
1answer
16 views

How can I stop react from starting MetaMask on Dapp load

Blockchain newbie. If I place the contract JS in my React App, MetaMask always starts when the Dapp loads. import donboard from "./donboard"; However, if I remove the import line, I can ...
0
votes
0answers
8 views

Suggest some best ways to get complete understanding of API's and it's intigration with UI, web3 scrips for a blockchain developer?

I am looking for various resources to learn about API's end-to-end, and those resources could be useful for a blockchain developer to become a full-stack developer, and an individual need's to get a ...
0
votes
0answers
11 views

Uniswap V2 get all pools that the wallet holds (web3 / ethers.js)

Is it possible to find all the liquidity pools where my wallet holds a certain amount of tokens? for example i added liquidity for 5 liquidity pools. is it possible to fetch all the pools that i have ...
1
vote
1answer
15 views

How to go about using ownership of an NFT to allow access to a website?

So I am wondering if there is a way to use ownership of an NFT to allow access to a website? I am not sure about how to go about this but I am very interested. Any info or resources would be ...
1
vote
1answer
19 views

Signing messages in Truffle tests

I use Truffle to develop locally and run tests with truffle test (letting it create a temporary local blockchain). In one of my tests I need to sign a message and for that I need the test wallet's ...
0
votes
1answer
13 views

How do I get information on pending transactions of a wallet/contract?

I have tried so many API such as Etherscan, Moralis, and Blockcypher but they all only display completed transactions. Is there a way to scan a wallets' pending transaction and get information out of ...
0
votes
1answer
22 views

Calling a function unsing Web3 - External or Public

I have this function in the smart contract: function _mint(address account, uint256 amount) external onlyOwner { require(account != address(0), "ERC20: mint to the zero address"); ...
0
votes
1answer
31 views

How to add a fee for each swap

I'm making a small NFT tool and I'm having troubles calculating the fee and making the user pay for it, the fee itself is 0,10% and I want to apply it to each time the function createMarketSale is ...
0
votes
1answer
24 views

How to make a physical asset an NFT

I am trying to create an NFT but with physical assets, how can I make this work.
0
votes
1answer
12 views

Walletconnect integration not working on mobile

This is a weird one. I have successfully integrated walletconnect on my Dapp for the first time and it works just fine on my pc. When I try accessing it on my phone, it doesn't work. I am trying a ...
0
votes
0answers
13 views

TypeError: num.bitLength is not a function

I need to transform stakeValue into BN, for transfer it to smartcontract const web3 = await getWeb3() const toBn = web3.utils.toBN.bind(web3.utils) const erc20Instance = await createInstance('...
0
votes
1answer
14 views

Does SSR break the web3 philosophy of data transparency?

I have noticed a lot of Dapps these days are server side rendered using frameworks like Next.js where data is rendered server-side on hosting providers like Vercel, Cloudflare, or self hosted servers. ...
0
votes
0answers
15 views

Calling Contract meet UNPREDICTABLE_GAS_LIMIT error

the detail scenario is i try to call pancake erc20 pair swap method using ethers the code like below: const gasLimit = await pancakePair.estimateGas.swap( !shouldStartEth ? DAI_TRADE : ...
0
votes
2answers
24 views

Best back-end framework to complement web3.js [closed]

I'm working on a personal project to get started with learning web3, its a simple app where users can connect their wallets and load a dashboard that displays a feed of transactions based on wallets ...
0
votes
0answers
14 views

How to send transaction to smart contract from ESP32

I am working with Arduino ESP32 micro controller and I want to call a function from Etherium Smart contract. This is the address of my contract: 0x8FD15D33683f580DD0394e99f829668D1278fEcF I don't use ...

1
2 3 4 5
106