What's the deal with Deno? We talk with a major contributor to find out. Listen now.

Questions tagged [bignumber]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
1answer
33 views

web3.utils.toWei(web3.utils.fromWei(…))

Is it warranted that web3.utils.toWei(web3.utils.fromWei(x)) is equal in numeric value to x (provided that x is a 256 bit number represented as a string)? If it is not warranted, how to obtain a value ...
0
votes
1answer
45 views

Error: invalid type (arg=“type”, value=“a”) web3.js

I am trying to get the balance of user for specific token type using web3.js. Here is my code block: var tokenContract = new web3.eth.Contract(erc20abi, tokenAddress) tokenContract.methods....
1
vote
1answer
303 views

Error: Returned error: The execution failed due to an exception. @ web3.eth.estimateGas

I am having problem using bignumber.js with web3: const sender = '0xss'; const recipient = '0xxx'; const amount = 1000; // have to use Bignumber for more than 1000 const decimals = 18; const ...
2
votes
1answer
49 views

Check emitted event with BN

I'm currently testing events that include numeric values: const level = new BN(1); truffleAssert.eventEmitted(tx, 'EventName', {level}); As you can see, the level variable is a BN, and holds the ...
2
votes
2answers
185 views

What big number library does ethers.js use?

Logging a value from a contract with ethers.js, gets me this: tokenBalance: v _hex: "0x033b2b2062ddfc98de7fffff" _ethersType: "BigNumber Is this an instance of bn.js, bignumber.js or a custom ...
0
votes
1answer
272 views

Can't log struct member in truffle test

Contract : mapping (bytes32 => MyStruct) public myMapping; struct MyStruct { uint256 myMember; uint256 someOtherMember; } Test (Truffle) This works: let ...
0
votes
3answers
162 views

Error: new BigNumber() not a base 16 number: at L (bignumber.js:3:2876)

I can not find what the problem is, someone can help me Contract pragma solidity ^0.5.9; contract certificarProceso { address public creador; address emisor; string informacion; ...
1
vote
2answers
283 views

How to convert smallest unit of ERC20 with less than 18 decimals to full coins without rounding errors?

I can just use web3's fromWei function for all token that have 18 decimal places but I'm not sure how to convert token to full token without having to worry about rounding errors. For example convert ...
0
votes
1answer
405 views

BigNumber Error: new BigNumber() not a base 16 number:

I'm new to Ethereum and javascript so hope someone can help me with this as none of the other answers on BigNumber help me understand why this won't work for me. I've tried converting the number to a ...
8
votes
3answers
2k views

How to use bignumbers in truffle tests?

I am testing a smartcontract with Truffle V5. All works well if I do not use all decimals. If I set 18 decimals all explodes. The test code is this (from truffle docs): const MetaCoin = artifacts....
0
votes
1answer
217 views

how to deal with large numbers in Ethereum?

I am confused with the use of large numbers in solidity, ethereum. I have some doubts please help me with them. 1) I am not able to represent the value of p using p.toNumber() but can represent it ...
1
vote
1answer
42 views

Issue with Contract function return value data type

I am using a simple contract Contract code contract Bank { address public owner; mapping(address => uint) private customerBalance; event fallbackCalled(address, uint256); event ...
0
votes
1answer
884 views

Contract deployment using web3.eth.contract(abi) with constructor arguments

I'm trying to deploy the following smart contract: pragma solidity ^0.5.00; contract TestContract { address public owner; string public word; constructor(string memory _word) public{ ...
0
votes
1answer
2k views

Error: Please pass numbers as strings or BigNumber objects to avoid precision errors

let result = await instance.joinQuiz({ from: accounts[1], value: web3.utils.toWei(10, "wei") });
0
votes
1answer
144 views

Doubt with ethereum-input-data-decoder when decoding a variable uint256

the input data of the variable uint256 is "22092018" but when using ethereum-input-data-decoder I return "BN: 15118f2". Instead of getting "BN: 15118f2" with the decoder, have the original value of ...
0
votes
1answer
113 views

How to define 2048-bit integers on smart contracts?

As we know solidity supports only 256-bit big integers. But for crypto primitives (sometimes) we need bigger integers, e.g. 2048-bit. Question: how can we define 2048-bit integers on a smart contract ...
0
votes
1answer
52 views

Is there a form of mapping with an even larger space?

I understand from here that the space for mapping() is drawn from a size of 2^256 * 32 bytes storage, which provides a 1 chance in 10^69 of overwrites. If I'm working with contracts on the order of ...
2
votes
1answer
2k views

How can we parse and deal with BigNumber (BN) args in Solidity events?

In the past, web3 events published numeric events like so: BigNumber { s: 1, e: 17, c: [ 1000 ] } } Now with web3.js 1.0, big numbers come down as objects like this: <BN: de0b6b3a7640000> ...
3
votes
2answers
2k views

How to convert big number to normal number?

I am new to testing and I want to know how to convert a big number to a real number. I use bignumber in the following command: console.log(await this.crowdsale.rate()); This is what gets printed in ...
4
votes
6answers
3k views

Error: Number can only safely store up to 53 bits

const result = await myContract.methods.myMethod(1).call(); brings the error from above. There is a simmilar questions here but since I use call gas shouldn't matter. I'm using "web3": "1.0.0-beta.35"...
1
vote
1answer
755 views

WEI to ETHER conversion issue with Web3 and Javascript

So i have a form where the user enters a price for an item in ETHER. I understand the blockchain does not handle floatin point numbers currently, so i am attempting to convert to WEI and store it on ...
1
vote
0answers
141 views

how do you handle token value data type in database?

Ones who do exchange / Investment platforms development, all ERC20 tokens has its atomic unit and only moved by specifying value in its atomic form. for eg: 1 BuritoToken with unit decimals as 18, ...
1
vote
1answer
134 views

how to parse the value returned by truffle? from balanceOf()

My question is nearly identical to: how to parse the value returned by truffle ? Except that when I run: bigNumberValue.toString() i get '[object Promise]' but then if I treat as a promise and ...
0
votes
2answers
795 views

How to store a Big Number?

I need to determine an expiry date for a contract a for this I use the foloowing code as the constructor of the contract : constructor(address _recipient, uint256 duration) public ...
0
votes
1answer
47 views

how do you convert (small) BigNumbers?

i created a variable called startDate using now in a smart contract. when reading it using Contract.startDate() it returns BigNumber { s: 1, e: 9, c: [ 1530272788 ] } how do i convert this to an ...
1
vote
0answers
314 views

How can I configure BigNumber class in Web3 Version 1.0.0?

Prior to version 1.0.0, I could do it like this, for example: web3.BigNumber.config({DECIMAL_PLACES: 100, ROUNDING_MODE: web3.BigNumber.ROUND_DOWN}); At version 1.0.0, it seems that web3.BigNumber ...
0
votes
1answer
539 views

Truffle Test - Solidity: How to access value of Promise object? [object Promise] [BigNumber]

a.getB.call().then(function (f) { console.log(f[1][0]) }); outputs: BigNumber { s: 1, e: 20, c: [ 5000000 ] } How can I access the value in c? How can I save object f to a javascript variable? ...
3
votes
1answer
735 views

How to convert bigNumber array to int array?

I have a smart contract method that return an array of uint256, but when I console.log the result I got this : [ BigNumber { s: 1, e: 1, c: [Array] } ] How can we convert it to array of numbers? ...
3
votes
1answer
1k views

Truffle CMD Bignumber to number; hex to string

A function in my contract when called on the truffle develop command line gives output in BigNumber format. Here is what I wrote on the command line: instance = contract.at('deployed address') ...
1
vote
1answer
630 views

how can i convert this number to arguments?

in this img you seen 570.1777 ext TRANSFER by function i want now how can convert this amount to arguments easy
3
votes
2answers
134 views

Ethereum scalability and user wait time

If I create a new app that will work on Ethereum network, it takes few seconds for a transaction to be confirmed at least once (creating a sub contract for example), so I can keep using other ...
3
votes
1answer
167 views

uint doesn't return big number object if function is not constant?

So, I have a contract deployed which has a simple function which returns a uint. If I make the function constant it returns the correct value set as a BigNumber object, but if I remove the constant ...
14
votes
4answers
22k views

How to convert BigNumber to Number in Truffle framework?

I have written an ERC20 token contract and deployed it in test network using truffle framework. When I check the token balance for an account using web3 it was giving the result in BigNumber when I ...
4
votes
1answer
49 views

Can I use the `e` notation on MyEtherWallet?

I just found out about the existence of the "minification" process. You probably know about it already, but if you don't, it basically means that 1000 = 10^3 = 1E3 . So 1000 minified is 1E3. Or 10'...
0
votes
3answers
544 views

eth.getPastLogs() requires exact match 32 byte value, how to get bignumber to emit?

the API eth.getPastLogs() requires 4 topics to match the log indexing capabilities of the EVM. It appears to require a full 32 byte number for the match to work. i.e. eth.getPastLogs((fromBlock:0, ...
1
vote
1answer
1k views

sendTransaction BigNumber Error: new BigNumber() not a number: [object Object]

I am new to Solidity programming and writing smart contracts for one of the application. Here are my two contracts. I am using truffle and testrpc as tool. I am getting error consistently. Need ...
8
votes
3answers
6k views

How do I send the entire ether balance from one account to another account?

I'm trying to use web3 to transfer all (or as much as I can) of the balance of an account to another account. Here is the code I have so far: var sender = web3.eth.accounts[0]; var receiver = web3....
3
votes
1answer
322 views

Ether transferred to Receiver's account is not exact

I'm trying to transfer to send some ether from one account to another in a smart contract written in Solidity. The transfer is successful but the amount received is not exactly matching up with the ...
13
votes
5answers
8k views

Getting Uncaught Error: new BigNumber() not a number: [object Object]

I am quite new to this. Please help me out. I am trying to build a dapp using meteor. I am having a little trouble with calling a function of the contract using web3. Here's the code snippet that's ...
2
votes
0answers
316 views

Optimizing 512-bit bigInt library

I mentioned last time that I was working on a big integer library. After some work, I have managed get 512-bit arithmetic kinda working!!!! Credits to /u/benjaminion for the modSmall function. Here ...
8
votes
1answer
2k views

How to pass numbers greater than 9007199254740991 to contracts?

When I try to call function check() with a number greater than 9007199254740991 I get an error: Error encoding arguments: Error: Assertion failed contract C { function rateCheck(uint rate){ ...
4
votes
0answers
298 views

Gas cost for bigInt library

I am working on a big integer library in the online compiler. Currently having gas/computational time issues with the modulus function. I first implemented it using repeated subtraction: function ...
2
votes
1answer
282 views

Sending tokens getting error

Hi i deployed a token contract in ethereum and managed to interact with it. solidity code : contract Token { mapping (address => uint) public balances; event TokenSent(address sender, address ...
1
vote
2answers
3k views

BigNumber issue — RequireJS and Web3

Here's my main.js file: require.config({ paths: { angular: '//ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular.min', web3: 'lib/web3', MainController: 'controllers/...
22
votes
1answer
7k views

What are *C*, *E* and *S* properties in message call return object?

(JS) var contract = web3.eth.contract(abiDefinition).at(address); contract.test(value, gotResult); function gotResult(error, result) { if(!error) { console.log(...