JavaScript is a dynamic, weakly-typed language used for client-side as well as server-side scripting.
Questions tagged [javascript]
1400 questions
12
votes
3 answers
Is it possible to send transaction in Binance Smart Chain using web3 and ethereumjs-tx?
I want to send transaction in Binance Smart Chain and I got an error: new Error("Chain with name " + chain + " not supported");
const Tx = require('ethereumjs-tx').Transaction;
const Web3 = require('web3');
const web3 = new…
AVorobev
- 123
- 1
- 1
- 4
5
votes
3 answers
Can a smart contract record IP address of a sender?
Can a smart contract record IP address of the one's using it? I mean, is it possible to implement on Solidity?
user12247
- 51
- 2
4
votes
1 answer
Javascript Question Regarding objects
I am hoping someone can explain how and why the answer to this question is... "Malibu".
Meet Sherlock Holmes, a world-renowned detective from London:
let sherlock = {
surname: 'Holmes',
address: { city: 'London' }
};
His friend, John Watson,…
Blockpain
- 173
- 1
- 9
3
votes
0 answers
Reconstruct sender address from signature
I am using a service that wants me to verify that the data it returns to me is correct before I use it. The service returns something that looks like the following:
{
"signature": {
"v": "28",
"r":…
tacoofdoomk
- 31
- 1
3
votes
2 answers
How to get the block number?
var test = await web3.eth.getBlockNumber();
I copied this code from the docs but when I call it I get this error:
TypeError: e is not a function
Anyone know what might be causing this?
I'm able to do
userAccountAddress = await…
Richard Garfield
- 1,017
- 2
- 10
- 14
3
votes
3 answers
Convert Ether to Wei without web3
I don't want to load the web3 library, I do however want to convert Either to Wei, does anyone have a JavaScript function to share.
I don't mind loading a smaller library
Bill
- 439
- 6
- 18
2
votes
1 answer
Dynamically calling a function on a contract
I'm trying to call different functions of a contract with a single function that has the function name passed to it as an argument.
var Web3 = require('web3');
const web3 = new Web3(new Web3.providers.HttpProvider('https://mainnet.infura.io'));
var…
Bill
- 439
- 6
- 18
1
vote
2 answers
TypeError: Cannot read property 'toNumber' of undefined
Cannot read property 'toNumber' of undefined?
Error message
1) Contract: DappTokenSale
ends token sale:
TypeError: Cannot read property 'toNumber' of undefined
at test/DappTokenSale.js:85:28
at…
zummon
- 23
- 1
- 3
1
vote
2 answers
Error in simple example code?
I'm playing around with truffle and I have this simple program here that I can't seem to get to work...
contract MyContract {
struct Test {
bool testBool;
}
mapping (address => Test[]) public tests;
function issueTest(address _owner)…
mark
- 209
- 1
- 7
1
vote
0 answers
How to write to a JSON file using fs?
For reference the code below writes a single array in a JSON file:
fs.writeFileSync(
"./users.json",
JSON.stringify(filteredArray),
"utf-8",
(err) => {
console.log(err);
}
);
And it writes to the JSON file something like…
Serenity
- 125
- 6
1
vote
1 answer
Scripts : what's the difference between exec file.js and js file.js?
The doc says that scripts can be executed with : geth --exec 'loadscript("script.js")' attach, but in the example script they give right after, they say to use geth js script.js 2>>geth.log.
What is the difference between the two ?
Teleporting Goat
- 1,516
- 1
- 13
- 33
0
votes
0 answers
How to get return value from a contract on JavaScript?
I am making a contract with a front-end made with JS, I studied myself how to make it work calling the functions with or without variables. But I don't know how to get the return value. I would appreciate your help.
On Remix it works fine.
The…
Zerohmaru
- 1
- 1
0
votes
1 answer
Get "i" in asynchrounous request
I have a view-request which returns amount X and will then fire a function X times through a for-loop. It works everything but due to the asynchronous request, I do not get the correct i-value that the function/request was fired with. The…
dkb
- 723
- 1
- 5
- 20
0
votes
1 answer
Access all elements in a mapping
I'm new to solidity. I am trying to access all elements in my Applicant struct. In my Donate function if the donor does not specify an organization to donate to, then the amount will be split across all organizations within applicants. I have looked…
Eli2099
- 39
- 4
0
votes
0 answers
Language bar not showing on github repository
Github repository is not showing the language of project. Repo Link :- https://github.com/shubhamextraxyz/Contract_Deployment_Infura_Web3.js
The file is a simple repo with 100% Javascript, but why it's not showing?
Any help appreciated!
Shubham
- 25
- 6