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
29 views

Type Error: web3.eth.Contract is not a constructor but web3.version is 1.0.0

Why can't I instantiate my smart contract? When I try and instantiate an instance of a smart contract with the following code... let contractInstance = new web3.eth.Contract(abi, '...
0
votes
1answer
12 views

function overriding is quite working when called with web3.js

function getDetails(address publicKey) public view returns (Organization memory) { return s.getOrg(publicKey); } function getDetails(string calldata orgID) external view returns (Organization ...
0
votes
0answers
16 views

Web3 method getTransactionReceipt() does not return token transfer value for particular token transaction

I've tested getTransactionReceipt(), to get all detail about transaction with amount of token transfer. Also tested getTransaction but it returns only Ether transferred value. Is there any other ...
0
votes
0answers
23 views

Smart contract function not returning value (decoded output) in Remix

I am completely new to Solidity and would appreciate any help. I have a supply chain smart contract and it contains a function that is supposed to be called by customers and after the call, the ...
0
votes
1answer
35 views

Web3 js installation error

I want to install webjs so I run the below command but it is showing an error. $ sudo npm install -g web3 npm ERR! path git npm ERR! code ENOENT npm ERR! errno ENOENT npm ERR! syscall spawn ...
1
vote
1answer
15 views

How can I generate random seed for new account of web3js?

I had created wallet account using web3.eth.accounts.wallet.create(). Now I want to generate random seed for that address. So which method of web3js will be helpful?
0
votes
1answer
10 views

how to call a function with ether through web3

I'm writing a simple DApp in webpack sample(metacoin) in truffle,there is a function that need to call with 2 ether and 1 input parameter. And my question is how to call that function in the index.js,...
0
votes
1answer
10 views

analyzing transaction cost for a smart contract

Given a smart contract, How do I figure out the total amount of gas used? Say for example a smart contract which has a parameterized constructor which stores 5 variables which are address type ...
0
votes
1answer
29 views

web3.js installation problem

I've ran into a problem trying to install web3. I went through here and stackover flow to try and solve the issue but had no success. I had to install python2.7 but still getting this error. Any ...
0
votes
1answer
12 views

Error: invalid address when I want send transaction

Trying to execute a contract function with web3 1.2.1. I have an Erc20 standard token. mintCoin: function(amount, sender, callback) { console.log(contractInstance.options.address); //all good ...
0
votes
1answer
33 views

How to connect project without web3 js npm package

I'm working with ASP.NET Core project and wanted to connect Blockchain with it. But the problem is, we don't want to use Web3 npm packages. Hence, I have added web3 js as follows <script src="...
0
votes
0answers
9 views

Contract not deploying with web3

I'm writing a web-based DApp with web3, and am trying to get my JavaScript to deploy a contract. I've set up the abi, contract, and bytecode as follows: const trade_abi = [ ... not shown: ABI copied ...
1
vote
3answers
37 views

Why web3.eth.getAccounts().then(console.log) return empty array?

It's really weird that I got empty array after I tried to web3.eth.getAccounts().then(console.log);and I also got a warning which is ./node_modules/web3-eth-accounts/src/scrypt.js Critical dependency: ...
0
votes
1answer
13 views

Why does webjs 1.0.0 cdn show api 0.20.7?

I have a project where rather than installing modules I have to import web3.js cdn. It's possible to find it here: https://cdn.jsdelivr.net/gh/ethereum/web3.js@1.0.0-beta.34/dist/ In the project ...
0
votes
1answer
24 views

Web3 - how to add WEI and ETH values correctly

I'm working on an auction feature in my DApp and having problems correctly adding together two WEI values. The contract stores two important values: 1. A minBidIncrement variable - which I've set to ...
0
votes
0answers
23 views

send().catch() doesn't give me the error message anymore

I'm using Truffle/Drizzle/MetaMask and calling methods with send() and using .then() and .catch() and I rely on getting the error message send to .catch() e.g. contract.methods['hello'](arg).send({ ...
0
votes
0answers
26 views

Getting empty events in response of receipt. I am using Infura+web3.js+ropsten

JS code contract.methods .myFunction( "data1", 1568545262, 1568631662, 1568718062, "0xD4496dA2a4b376fC8s4d786EB6B71483436077c4" ) .send({ from: "...
0
votes
1answer
16 views

How DApp actually talks to Ganache ethereum node?

Both Metamask and web3.js seems to be enabling a DApp communicates to a remote ethereum node. There are a few different aspects to developing blockchain applications with Ethereum: Smart ...
1
vote
0answers
18 views

How to allow mobile wallets to sign and access to my dapp

I'm building a dapp application on Ethereum using React & Web3js. As usual the dapp will get the injected provider from Window.web3 (MetaMask), perhaps. The problem that I'm facing now is how can ...
0
votes
0answers
21 views

contract not deployed [closed]

I am getting this error in the browser console and dont what to do please help... ERROR Error: Uncaught (in promise): Error: Contract has not been deployed to detected network (network/artifact ...
0
votes
1answer
53 views

Web3-core-helpers error: Uncaught (in promise) Error: Provided address “undefined” is invalid,

When I launch the app with with react.. this error occur when my exchange contract is loaded.. Here is the code i wrote to talk to the blockchain: export const loadBalances = async (dispatch, web3, ...
0
votes
1answer
60 views

MetaMask - RPC Error: Internal JSON-RPC error

I am getting this error when i trying to use metamask on my local for a simple transaction from one account(say A) to another (say B). code: -32603 data: {originalError: {…}} message: "Internal ...
1
vote
1answer
19 views

Duplication of events in permissioned geth Chain with clique PoA consensus algorithm

I have an Ethereum chain running on my local host via geth and i am using the clique PoA Algorithm. I have 4 authority nodes so the number of Nodes allowed to sign a block should always be 1 because ...
1
vote
1answer
24 views

str.slice is not a function

I ran two command lines of web3 and it returned an error > length ='0000000000000000000000000000000000000000000000000000000000000002' ...
0
votes
1answer
22 views

Verifying if a user actually owns the address

Web3js frontend with Vue, .NET Core with Nethereum at the back. The key target for this functionality is to sign a message at the frontend, send the signature and the address to the backend to ...
0
votes
1answer
25 views

BigNumber string error when passed as uint256

I get the following error when passing (new BigNumber('2')).exponentiatedBy(100) big number value as uint256 Error: invalid BigNumber string value (arg="value", value="1....
0
votes
1answer
19 views

how to broadcast ethereum signed transaction without web3.js or any other web3 library/client

Is there any secure and reliable way of broadcasting signed Ethereum transaction without using Web3 library like with some service and some sort of HTTP API?
0
votes
1answer
22 views

Solidity - preventing negative uint parameters/overflow

Since web3 apparently doesn't require functions with uint parameters to have positive values for those parameters, I thought I'd try it in Solidity. I'm posting this to see if I'm overthinking it, if ...
0
votes
0answers
26 views

Getting Metamask Error Message into web3.js DApp after user rejects transaction

I'm building a simple HTML/JavaScript front-end to interact with a Smart Contract using web3.js and MetaMask. I have a function to call one of the methods in order to send a contribution to the Smart ...
0
votes
1answer
34 views

Transaction being reverted by EVM during contract creation (Web3 / ethereumjs-tx)

Hey guys I am running into an issue deploying a smart contract with Web3 to the Ropsten network. The code is running seemingly correctly, and there is a contract address being created, but if I check ...
1
vote
2answers
41 views

How to test a custom fallback function using web3.js?

I am trying to implement a proxy pattern. I have a proxy contract and a lottery contract, and I would like the proxy contract to delegate calls to the lottery contract. To test that the function ...
0
votes
1answer
21 views

Two smart contracts interact can't pass value when I using web3.js

I have two different smart contracts interaction_1 and interaction_2 I input the data(team) from remix ide. What I want to accomplish is when user input team in user_input function at interaction_1,...
0
votes
0answers
11 views

subscriptions in Geth or Parity

I am trying to get the way to register subscriptions to events, with the services of QuikNode I can do it without problem and it is working perfect, but I am trying to raise a node --light with geth ...
0
votes
0answers
26 views

not able to assign address to a public property using web3

while everything is working fine when working on remix ide but on truffle its not updaing value of a property (player2) i am also returning that address value and its returning as it should be. but ...
0
votes
0answers
36 views

Can not tranfer eth with solidity and web3js

Error when I try to send eth from fontend react to smart contract and from contract I tranfer eth to another address but it error, when I try it in remix then it total work. I user web3js to call ...
0
votes
0answers
14 views

ethereum deposit notice(hook)

I want to detect that someone sent coin to my wallet. (ethereum deposit notice(hook)) I will use web3 api. The easiest way is to search the latest blocks for my address. I don't think it's an ...
0
votes
0answers
18 views

Is Gas consumed in boolean operations that do not change contract state?

Imagine I've created a voting contract, and I'm the owner of this contract. I'm going to deploy it and create a front end to interact with it. Within my contract i've everything secured to add ...
0
votes
0answers
26 views

Geth web3.eth.contract returns null

I understand that the way I'm doing this is a bit backwards, but I cannot install node.js onto our server, and we are using a PHP backend which doesn't have very good Ethereum support. I am trying to ...
0
votes
1answer
34 views

web3 - web3.utils.toHex zeros length

I'm trying to send 12 integer as bytes to a contract function. If I use web3.utils.toHex(12) the variable will become 0xc The problem is that when contract function parses bytes, it reads uint256, ...
0
votes
1answer
15 views

Geth + Web3 | web3.eth.getAccounts() returns undefined

I have follow this SO answer for sending ERC20 tokens from 1 address to another. I am running into an issue where I am receiving an error that my from address is invalid Error: Error: ...
0
votes
0answers
28 views

How to connect to MetaMask via web3js

I'm trying to recreate this site TenThousandSu And this is the smart contract I'm trying to call https://rinkeby.etherscan.io/address/0x7e338acfb7a5d7e99f4225cc12dc884f49c00f6a#code I'm using "1.0....
0
votes
0answers
25 views

web3.utils.toHex but combined, hex concat?

I'm currently working with bytes in Remix. The goal I wanted to achieve was to put variables into bytes in one function, copy bytes, paste bytes to another function as a parameter and unpack these ...
0
votes
0answers
10 views

Web3.providers.WebsocketProvider — timeout and other network specific stuff

I'm looking here: https://web3js.readthedocs.io/en/v1.2.0/web3-eth-personal.html#providers This works fine for me, however I'm wondering how to specify things like timeout and other networks ...
0
votes
0answers
28 views

web3 - Can I call a library function without a contract?

I have a library which contains a function concat - it can merge two bytes. I have deployed a contract which uses that library and it works. I would like to make a simple bytes builder on my website. ...
0
votes
1answer
23 views

How to extract or create a message with web3.js to sign with an external hardware device?

I'm using the Web3 library. I want to extract a signature hash from a Web3 transaction to send to an external hardware device, sign it there, then use the signature I get from there to broadcast my ...
0
votes
1answer
42 views

Filters object not working for web3.eth.contract getPastEvents() method

I have referred, Web3 Events, but filters object is not working for me, I've got the same result for events before and after applying filter object. Here's the code: instance.getPastEvents( "...
0
votes
1answer
47 views

How to connect with WebSocket with Web3?

Already referred web3 documentations and other Q-A for web socket connection. Currently using infura as provider.
0
votes
1answer
22 views

Not getting getPastEvents or once function using contract instance

I have followed Web3 documentation to subscribe an evnet, I have created Instance of web3 using infura url as argument. Created contract object using, const contract = web3.eth.contract(abi, ...
0
votes
1answer
121 views

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory

I am trying to run the follow code that queries an address to track the balance of an ERC 20 Token through the chain's. Eventually I plan on running a big array of account through all the blocks track ...
0
votes
1answer
18 views

Passing blocknumber to eth.contract.method.balanceOf

I read that there is an option to pass blocknumber to contract.methods.balanceOf I am currently passing it like this: const address ='0x6C1F09F6271fbE133Db38DB9c9280307F5d22160'; contract.methods....