Skip to main content

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
1 answer
2k views

Proper way of using allEvents()

I'm trying to get all events for a contract: let events = token.allEvents({fromBlock: creationBlock, toBlock: 'latest'}, (err, res) => { try { let result = events.get(); ...
0 votes
1 answer
438 views

TypeError [ERR_INVALID_ARG_TYPE] web3.js error

Can anyone help me fix this problem? I keep getting 'throw new ERR_INVALID_ARG_TYPE( ^ TypeError [ERR_INVALID_ARG_TYPE]: The first argument must be one of type string, Buffer, ArrayBuffer, Array, or ...
0 votes
1 answer
11 views

Error uploading file: Cannot read properties of undefined (reading 'add')

const ImgHash = `https://gateway.pinata.cloud/ipfs/${resFile.data.IpfsHash}`; // Correcting the contract call await contract.add(account, ImgHash); alert("...
0 votes
1 answer
409 views

Problem deploying a smart contract in web3 to the Ropsten testnet

I am having trouble deploying a smart contract to the Ropsten testnet. I have dug through a lot of tutorials and questions and I cannot seem to find an suitable answer. Thanks so much for you time! ...
2 votes
1 answer
2k views

Nethereum and Metamask via Asp.Net?

I'm using Nethereum on the server currently, manually creating Account objects using private keys copied/pasted from a MetaMask wallet. I'm now trying to build access to this functionality through ...
0 votes
1 answer
1k views

Accessing older blocks from Geth: Returned error: missing trie node 94d34

When my Nodejs script uses web3 to query a geth node running in a private Ethereum network for an older block, I encounter the error UnhandledPromiseRejectionWarning: Error: Returned error: missing ...
0 votes
1 answer
313 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: ...
1 vote
2 answers
1k views

web3.eth.getAccounts() : Cannot read property 'map' of undefined

const HDWalletProvider = require('truffle-hdwallet-provider'); const Web3 = require('web3'); const provider = new HDWalletProvider( 'passphrase', 'rinkeby.infura.io/v3/mytoken' ); const web3 = new ...
1 vote
1 answer
444 views

GetPastEvents and string topic - Error: invalid argument 0: hex has invalid length 160 after decoding; expected 32 for topic

Being "token" below a contract instance, i do: token.getPastEvents('OperationEvent', {fromBlock:68000000, filter: {productId: '...
0 votes
2 answers
529 views

how can i send a transaction in spesific block numbers with web3Js?

I wanna know how to send the transaction in spesific block numbers with web3js ( Yes its for sniping bot ) The purpose is to avoid the tax in 1-3 blocks since liquidity is added For example : New ...
3 votes
1 answer
747 views

Can i delete some old files inside chaindata folder?

I am running geth with fast sync, Can i delete some old files inside chaindata folder so that my ssd will have some empty space or it will create some problems ?
0 votes
1 answer
2k views

How to connect a MetaMask account to a DApp in the MetaMask Application?

I created a DApp that uses MetaMask to interact with the ethereum blockchain. The DApp works wonderfully in the desktop browser while using MetaMask as a browser extension. Now I want to confirm that ...
1 vote
1 answer
675 views

How to simulate multiple consecutive transactions and get the resulting state?

I'm trying to simulate a transaction on the public blockchain that invokes a contract's method with certain parameters. Then I want to make a follow-up transaction with some other method call. I ...
0 votes
1 answer
1k views

What are Ethereum Genesis transactions?

I recently came across these transactions on Ethereum that don't have a typical transaction hash. They are sent by a wallet named "GENESIS," which is not associated with any specific address ...
2 votes
1 answer
312 views

How to check whether the keystore file has been tampered?

The format of the keystore is shown below. In the project, there is a requirement to save the keystore file from the front end to the back end. How can the back end check whether the keystore file has ...
0 votes
0 answers
6 views

Difference between sign-in with web3 library using MetaMask and SpruceID SSX tool?

I am making a decentralized attestation dapp with React. I found that SpruceId provides some tools for sign-in with Ethereum (namely, SpruceID SSX). What is the difference with a conventional approach ...
1 vote
1 answer
1k views

Smart Contract is being deployed but call does not return contract address after deployment

So I have been trying to deploy a smart contract using nodejs, but when I call the function to deploy, I get no contract address on my console. It's like the send() function never completed its ...
0 votes
1 answer
840 views

Web3 provider returns object. Need to store the provider in localstorage

I have a set of function in my react application which I want to connect to the web3 modal. I use Web3 and web3modal for connecting with different wallets. Here is my code: import axios from "...
1 vote
1 answer
407 views

How to run a simple Whisper (SHH) example

I am struggling to get a simple whisper (shh) example running. I am using the following versions: geth 1.9.24-stable-cc05b050 web3 6.14.5 I am running geth with the following command: geth --shh --rpc ...
1 vote
1 answer
1k views

"couldn't decode uint8 from ABI: 0x" when returning a large fixed array with web3

I'm trying to return a fixed size array. It works fine with a uint8 array of up to 360000 or so. I've only tested on the rinkeby testnet so far. I've tried increasing the gas limit for my call but ...
0 votes
1 answer
339 views

Metamask false positive error: ERC20 transferFrom tx displays "Exception thrown" error in metamask, but tx confirms fine

I'm fairly certainly this is due to approvals- that metamask thinks that an error will be thrown because the contract does not have approval to transfer the ERC20- even though the approval tx is ...
0 votes
2 answers
1k views

Get enum value from smart contract with javascript

This is my contract: enum State { Active, Refunding, Pending, Releasing} function state(uint orderid) public view returns (State) { return State.Releasing; } In one Javascript to ...
2 votes
2 answers
1k views

The method eth_compileSolidity does not exist/is not available at Object.InvalidResponse stacktrace

I am new to Ethereum. Trying to run a smart contract. I verified the contract content by running it on online compiler. But I am getting an error at the following line of code. var simpleCompiled = ...
2 votes
1 answer
596 views

Exceeds block gas limit error to call view functions

With solidity view function, you can specific the amount of gas to use. My understand is since it is not a state changing transaction, all the gas cost is not charged for, and the client should be ...
1 vote
2 answers
2k views

Out of gas when calling smart contract function from web3/Meteor Dapp

The following smart contract function works when called in the Remix-Solidity IDE and connected to testrpc. function submitAsset(string ownerName, string assetName, string assetDesc, string barcode, ...
1 vote
2 answers
388 views

Solidity: Reading events with web3.eth.contract

I am trying to read events issued on my hardhat local node. My code is the following var fs = require('fs'); var jsonFile = "artifacts/contracts/STPOAP_ERC.sol/STPOAP_ERC.json"; var parsed= ...
0 votes
1 answer
335 views

Unable to send ether to account

I am trying to send ehter using this code web3.eth.accounts.wallet.add(privateKey); web3.eth.sendTransaction({ to:someAddress, from:onwer, value:amount*1, ...
0 votes
1 answer
439 views

Passing objects from web3 to smart contract

I have a contract in which there is a function which has 16 arguments which is giving me stack too deep error. So I am thinking of passing a javascript object using web3 to the smart contract which I ...
1 vote
3 answers
332 views

Get all connected wallet ERC-721 tokens javascript

Is it possible to retrieve all ERC-721 tokens and associated contract addresses from a connected wallet in javascript? I would like to do this without using an API like Alchemy (because I use a ...
0 votes
1 answer
3k views

Input data on Solidity

I'm trying to do something simple like Hello World that shows on a webpage. I've written a smart contract like this: pragma solidity ^0.4.18; contract HelloContract { string word = "Hello World!"...
0 votes
2 answers
768 views

@ethereumjs/tx - "TypeError: Common is not a constructor"

I was trying to implement a method for signing an eip-1559 transaction using @ethereumjs/tx package. While following the steps mentioned in their documentation , I am encountering an error when trying ...
0 votes
1 answer
602 views

Why myContract.events.MyEvent([options][, callback]) does not return "data" and "logs"?

We have an event as follows : event LogNewObject(address sender, bytes32 indexed id, bytes32 sub_states_types, bytes32 sub_states_values, address owner); This event is called in following function : ...
0 votes
1 answer
395 views

Is it possible to retrieve list of events signature/name of a Contract Address?

I have a contract address and its ABI. How can I retrieve all the events emitted by the contract?
0 votes
1 answer
329 views

How to download and install Echidna?

I have just started learning echidna but i havent found any detailed information of how to install and setup echidna in WSL.
0 votes
1 answer
2k views

How to sign transaction from frontend with metamask and then send that signed data to rest api for submitting the transaction?

I have a front end connected with metamask wallet and a rest API layer. My requirement is to sign the transaction from metamask and then to send the signed transaction to rest api to submit the ...
1 vote
1 answer
3k views

Getting "Error: unknown account at Object.InvalidResponse" when appication is connected to private network using metamask

My Contract is: pragma solidity ^0.4.8; contract Awards { address public owner; string  public name1; string  public name2; string  public name3; function Awards() {   owner = msg....
1 vote
0 answers
14 views

How to fetch ENS domain details

I want a functionality using which i can get the address by passing a domain name for multiple domains like .eth,.bnb,.arb,.polygon. I tried multiple servcies but most of them only supports .eth , i ...
0 votes
1 answer
17 views

web3.py Increase the amount of gas to make the transaction faster in the blockchain

My goal is to have my transaction included in the blockchain as soon as possible. This code, includes the transaction in the blockchain in 5-7 seconds in eth and polygon. tx = { 'from': w3....
0 votes
1 answer
376 views

Can I store ether and ERC-20 tokens in one contract?

I am trying to create a contract to store ether and two ERC-20 tokens. People will transfer ether and the other two ERC-20 tokens to this contract and when the time comes, the owner of this contract ...
1 vote
1 answer
666 views

How to deploy a contract using metamask and the callback?

I'm trying to deploy a new contract with metamask (in my javascript frontend app). The problem is that, when the receipt is returned, the address is "undefined" since, I suppose, the transaction is ...
0 votes
1 answer
353 views

How to create a gnosis safe using the gnosis smart contracts and ethers.js?

I'm trying to create a gnosis safe using ethers.js and gnosis smart contract but when I see the GnosisSafe Smart Contract(https://etherscan.io/address/0xd9Db270c1B5E3Bd161E8c8503c55cEABeE709552#code) ...
0 votes
0 answers
25 views

"npx thirdweb@latest create --contract " command error "module not found"

PS C:\Users\Dhwanan\Desktop\web3> npx thirdweb@latest create --contract node:internal/modules/cjs/loader:1080 throw err; ^ Error: Cannot find module './bases/identity.js' Require stack: - C:\...
0 votes
1 answer
11 views

Problems calling functions with web3 from python from polygon testnet

I was trying to call a function from my python server to a contract deployed on cardona testnet polygon zkevm. This is my contract: require(bytes(filename).length > 0, "Filename cannot ...
0 votes
1 answer
426 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(&...
0 votes
1 answer
386 views

Transaction response doesn't contain "receipt" value

i'm doing this send function let result = await myContract.methods.myMethod().send({from: account}); console.log("result:", result); using web3.js ^1.2.2 on testRPC with Ganache, hardfork Byzantium, ...
0 votes
2 answers
73 views

What is the best way to monitor all token balances of wallet address?

Context I'm developing a personal project to monitor token balances of all wallet addresses in my service . I can monitor token balances of several addresses by multicall. I designed my workflow of ...
7 votes
2 answers
1k views

Unit testing a Solidity Library function with a struct memory argument

I am trying to unit test a Solidity Library contract function using truffle and web3. My simplified Library contract looks like this: pragma solidity >=0.5.16; pragma experimental ABIEncoderV2; ...
1 vote
1 answer
735 views

How to use web3-react with truffle Dapp? any sample code / tutorial?

I am new to react and finding issues with the front-end of the Dapp application. Especially in web3 version > web3 1.0.0 I just heard about the web3-react and I think it will be a lot easier. I ...
0 votes
1 answer
719 views

How to deploy a truffle built Dapp

I've completed my truffle Dapp, the contracts are deployed to the Ropsten test network and my web code talks nicely to them, it works great from http://localhost:8080/ when I do an npm run dev. I now ...
0 votes
1 answer
973 views

Truffle console showing irrelevant balance irrelevant BN{ negative: 0, words: [ 16777216, 62077800, 20718012, <1 empty item> ], length: 4, red: null }

I'm using ganache network, truffle network, web3, chai and mocha. while using truffle console in terminal it shows: truffle(develompment)> balance BN { negative: 0, words: [ 16777216, 62077800, ...

1
2 3 4 5
124