Questions tagged [javascript]

JavaScript is a dynamic, weakly-typed language used for client-side as well as server-side scripting.

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

base fee exceeds gas limit , error when deploying using encoded constructor

I have following small simple contract pragma solidity 0.4.24; contract MyContract { uint256 public totalSupply ; mapping( address => uint256) public balances ; address public ...
0
votes
0answers
11 views

EIP-712 typed signature for arrays

I'm trying to generate a typed signature for an array in JavaScript based on EIP-712 and using eth-sig-util. My problem is that I need to sign an array. It says in the specification to use Type[] or ...
1
vote
1answer
13 views

how to create Function Selector (Method IDs)

As stated in ABI specs that 0xcdcd77c0: the Method ID. This is derived as the first 4 bytes of the Keccak hash of the ASCII form of the signature baz(uint32,bool). So, I have to create method IDs (...
0
votes
0answers
17 views

TypeError: CreateListFromArrayLike called on non-object

I have this contract and deployed it to my local client (ganache gui) and its abi.json file (of solc compiler generated). The third file is param.txt which contains encoded functions with arguments ...
-1
votes
1answer
32 views

Using await with web3 function calls

I have just implemented a tweak to make my asynchronous call run sequentially, however it is messy solution. I have got the following code: async function myClick() { calculateAmounts(); ...
0
votes
0answers
11 views

Compiling Old Version Contracts , gives ParserError: Expected pragma, import directive or contract/interface/library definition

Ihave to compile some old contracts (having solidity pragma is <0.5. For this purpose, I have just copy and paste this contract from Etehrscan and save with its name in contracts folder. Install ...
0
votes
0answers
15 views

Solc Compiler related Error in Nodejs

I have almost 800 .solc files of version ^0.5.12 (i am using also 0.5.13 compiler version), when i all give them to my input, to compile with following code; var walk = function (dir) { var ...
0
votes
1answer
15 views

TypeError: _getWeb3__WEBPACK_IMPORTED_MODULE_0__.default.eth is undefined

I'm not familiar with webpack, but after reading this error all I know that I import one module that is undefined by webpack. However, I don't know why export default new web3.eth.Contract(abi, ...
0
votes
2answers
13 views

Recovering of typed signature fails because it's too long

I have a typed signature generated by EIP712 V3. It is 132 characters long. I'm trying to recover it using recoverTypedSignature from eth-sig-util. This fails saying: index.js:1 Error: Invalid ...
0
votes
0answers
5 views

How to recover a signature on the server side?

I need to verify the signer of a signature in my node server. const fortmaticApiKey = 'pk_live_...'; const checkPersonalSignature = async (data, signature, signer) => { try { const { get } =...
0
votes
1answer
20 views

Error: Uncaught [TypeError: Cannot read property 'ContractName' of undefined]

I am trying to get source of open source verified contracts and write into a file at my local folder. I could write only one file (of first address) but for the rest i am facing captioned error. ...
0
votes
1answer
22 views

Invalid Address format - Etherscan.io APIs problem

I have download list of verified open source contract addresses's list and loaded into addresses[]. Now I want to download sourcecode/ABIs etc... of that contracts. Although, i have called setTimeOut ...
0
votes
0answers
30 views

Could not find declaration module for file 'solc'

I was trying with a simple contract,when I do "node compile.js" in my windows cmd it throws an error.I was using vscode it showing error in const solc = require('solc'),I installed everything ...
0
votes
0answers
26 views

Error: Cross origin null forbidden : ---Problem in downloading Open source contracts from Etherscan.io

UPDATED: I am trying to download source code of open source verified contract from Etherscan.io. Here is my procedure as directed by Ann. 1. Download CSV file of captioned contracts. 2. Write ...
1
vote
0answers
24 views

How to check current status of state variables

I have deployed my contract locally into Ganache (GUI) and then send/call lot of transactions. After these transactions, now I want to check the current status of all state variables. Is there any way/...
0
votes
1answer
31 views

How to download contracts by address from Etherscan using web3.js

I want to download all contracts (open source code) from etherscan.io using Web3js. Etherscan gives only the list of such verified open source contract with txHash, name, and their addresses. Is there ...
0
votes
1answer
23 views

Storing code in contracts

I'm considering different designs to implement "configuration options" with Ethereum. The design should allow me to define arbitrary (= number and type) options, quick access to a list of options, ...
0
votes
1answer
17 views

Could not deploy contract with valid data

I have downloaded contracts with their abi and json. I have to deploy them. when i extract bytecode from downloaded files and then assign it to my data variable to deploy contract whic gives following ...
0
votes
1answer
17 views

How can fix in smart contract written in solidity?

TypeError: Invalid type for argument in function call. Invalid implicit conversion from address to address payable requested. selfdestruct(admin); pragma solidity >=0.4.21 <0.6.0; ...
0
votes
1answer
15 views

Could not deploy contract through sendTransaction

I am trying to deploy contract (available at Etherscan.io ). I proceed following steps: copy its contract creation code and save them in crCode variable. Then i tried to to run following code; async ...
0
votes
0answers
15 views

Dataset of simple contracts with getter setters

Are there any repositories/datasets which provide smart contract with simple logic like having some getters and setter functions. So, that I could give some values to getter and setter functions, ...
0
votes
1answer
37 views

Ganache VM Exception while processing transaction: out of gas

I am deploying my contract using web3 by taking values (just copy paste) from Etherscan (i.e. abi, contract creation code, etc.) and then deploy my contract on Ganache (gui). When i run the my code ...
0
votes
1answer
21 views

UnhandledPromiseRejectionWarning: Error: invalid address (arg=“”, coderType=“address”

First of all, i extracting function from abi of my contract and calling them automatically. As per documentation of solidity, when we compile .sol, some functions are automatically generated as per ...
0
votes
1answer
12 views

Ganache is not updating my contract status

I am using ganche for local ethereum. I have successfully deployed my contract through web3js on ganache. (The same contract also tested on Remix, all function properly running as per logic). Now i ...
0
votes
0answers
24 views

creating transaction with dynamic arguments (objects/variables)

My scenario is to make transactions (deploy contract, calling its functions, etc.) with arguments (which are dynamically created/extracted from some json abi file). For example; function ...
1
vote
1answer
18 views

Automatically extracting functions names and parameters from ABI JSON file

I have done some work on captioned subject. For example, I can extract all getter functions (and some constructors as well) of all given smart contracts (in abi json file format). Then i can call (...
0
votes
1answer
19 views

Could not call contract function with its signature

Web3.js documentation says here that the methods of a smart contract are available through: The name: myContract.methods.myMethod The name with parameters: myContract.methods['myMethod(uint256)'] The ...
0
votes
1answer
39 views

Calling contract functions using only ABI without source code

I have MyContract.json file of some contract(assume i haven't its source code). In .json file, there is abi and bytecode. If i want to deploy such contract (through web3js), I am facing following ...
0
votes
0answers
12 views

Extract function names alongwith their parameter name and types from abi JSON file

My task is to get function names, its parameters and type of parameters from provided .json file. Then call each extracted function with extracted parameters. The code from this Get all function names ...
1
vote
1answer
13 views

Different behavior of the same contract between JavaScript and Solidity tests with Truffle

I have a simple contract that functions as a ratekeeper - it is constructed with a capacity and time_frame (in blocks) parameters and makes sure we never add more than $capacity payments in any given ...
0
votes
1answer
22 views

eth_getBlockByNumber returning undefined

I have some JavaScript that's connecting to a private ethereum network via JSON-RPC. I am trying to extract the transaction hash of the blocks but am unable to do so. // BlockNumber clientNodeOne....
0
votes
1answer
21 views

Could not call contract function

I want to access the balance of contract(i.e. 0x552F3AfaA0394632f4aEfa9E923fA3e2bbDAF5FE) and its totalSupply(state variable). I could access the balancec of this contract , but why I could not call ...
0
votes
1answer
43 views

How to deploy and get address of smart contract in same javascript program

I want to deploy a smart contract (provided in .json file) and need its address (on testnet blockchain) and then try to send some transactions to it. All these should be done through javascript. Here ...
0
votes
2answers
40 views

Ethers.js: Call constant method with await does not work [closed]

If I try to get the result of a constant function call with: let gameCountAwait = await contract.getGameEntry(0); it fails with: Uncaught SyntaxError: await is only valid in async function ...
0
votes
1answer
26 views

How to call external payable contract function from app.js (DApp)?

The contract has a function: function purchaseTokens() external payable { require(msg.value>0); ...etceteras... } What I need is an app.js part, something that would look like this (lets ...
0
votes
1answer
16 views

How to know the execution time of transaction when miner execute it

When i send three consecutive transactions to my contract (deployed on ethereum testnet), how can i know the exact time (at milli/micro/nano level) which transaction executed (on miner side) first and ...
0
votes
1answer
28 views

State Variable of solidity Contract could not be updated through JavaScript

I have following contract and just want to update its state variable values i.e. totalSupply. But when I try to attempt this task through JavaScript code (given below) by calling its function i.e. ...
0
votes
3answers
32 views

Could not assign contract state variable value to javascript variable

I want to retrieve and assign the value of my contract state variable to my javascript variable.I am doing as per guidlines provided on this community, but failed to assigned. my javascript code is ...
0
votes
1answer
36 views

Erc20 address generation

Can someone tell me how it is possible to implement the generation of unique erc20 addresses for registered users?
0
votes
1answer
36 views

How to build security into Dapps?

I am building a loan dapp. The functionality is not easy to build but relatively straightforward. My question is though does anyone have any suggestions of how to build in user logins and security? ...
0
votes
2answers
99 views

Truffle - Get ETH Balance with Web3JS - two different errors

Using "web3": "1.0.0-beta.46" because doing a tutorial, and they recommended using all his versions to make sure everything works together. Using Gnache and Truffle unit tests, I have tried two ...
0
votes
1answer
19 views

Truffle returning balances from a function

This maybe just a simple Javascript issue, but it's in the context of running under Truffle. I can't seem to access my object variables coming back from my function; thus the tests are failing with ...
0
votes
1answer
28 views

How can a smart contract payable based function returns value against any purchase

I am trying to get a return value from the payable function, the idea is a user must pay the fees and in return, he will get his special code. My JS test code is as follow it('get special code ...
0
votes
0answers
15 views

cloning div container number of deployed child contracts time and put their data inside div container

Sorry for the silly question. I have a div container "product-card" , I want to loop the number of my deployed smart contracts time. every time when I loop I want to clone this div container and ...
0
votes
0answers
24 views

Recursive binary search function (in solidity) not working

This is recursive binary search function in solidity. I run the SortTESTER function to populate an array with values. Then I run the SortUserData function to check values which passes the values to ...
0
votes
0answers
14 views

RSA signature verification: Inputs to Precompile contract

I am trying to verify an RSA signature using Ethereum smart contract. I have some doubts regarding my design. I am using the precompile at address 0X05 to generate s^e mod n, where s is the ...
0
votes
0answers
12 views

How to Convert TransactionHash (SendETH) to Variable?

I have created a function to send Ethereum and it can run inside console.log. With a simple code call a function like this: var sendEth = sendMoney(data).then(hash => { console.log(hash....
0
votes
1answer
34 views

web3js later versions. Bundle, how?

I'm trying to build the frontend of a dApp, but the web3js makes my head hurt. I need to include it in my project, but the latest web3.min.js i can find is this. I want to use 1.2.1, and i understand ...
0
votes
1answer
70 views

Unable to Verify Smart Contract

Currently I want to make a smart contract for verifying documents. However, I couldn't make it works. I have followed the tutorials as shown here (it is for Solidity 0.4.4 and mine is solidity 0.5.0) ...
0
votes
1answer
33 views

Emited Solidity Events not being watched at frontend truffle contract instance

So, I have been reading through A LOT of pages about events in Solidity and how to interact with them on frontend but I am still pretty new to this and it seems like there have been multiple changes, ...