Questions tagged [solidity]

Solidity is a contract-oriented, high-level language whose syntax is similar to that of JavaScript and it is designed for writing smart contracts in Ethereum to run on the EVM. Solidity is statically typed, supports inheritance, libraries and complex user-defined types among other features.

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

External function call solidity

Assuming that I don’t know the contract A, I just know its address, and that it has a setNumber method that I want to call it from contract B. I want to call the function setNumber in contract A, ...
0
votes
1answer
9 views

What is the gas cost of recovering a wallet address from a signature using Solidity?

As titled. I understand that there's an ecrecover function in Solidity. Can I use it for recovering a wallet address from a signature? Is it cheaper than a Keccak hash operation?
0
votes
1answer
32 views

Web3 hex conversion - Reading Events Output

Using the following code in Nodejs - Web3 to catch event from Solidity Smart Contract: const cron = require("node-cron"); const Web3 = require("web3"); const ABISimpleStorage = require("./build/...
0
votes
1answer
13 views

What is the receive keyword in solidity?

Solidity has a receive keyword. What is it and how do I use it?
1
vote
1answer
11 views

Forward all function calls and arguments to another contract

I want to build a truly upgradable contract. I want the child contract to only implement state and then forward all functional requests to a main implementation contract. So the scheme should look ...
0
votes
1answer
17 views

Contract inheritance to share same storage in Proxy pattern for upgradeability

Please bear with me here, I have been trying to figure it out myself but couldn't. I am trying to learn upgradeability with a Proxy pattern .https://blog.gnosis.pm/solidity-delegateproxy-contracts-...
0
votes
1answer
8 views

“TypeError” for a simple program causing failure to compile, “Type address is not implicitly convertible to expected type address payable.”

This is my first contract (working from Lynda course). Even when I use the supplied code I still age this error for the following code with I try to compile: TypeError: Type address is not implicitly ...
1
vote
2answers
20 views

Duplicate data in “returnValues” field of event emitted in solidity script

I am using quoram distribution through Azure blockchain service.. we are emitting few events according to our logic and these events are being used to get specific data from the transaction.. though ...
0
votes
0answers
8 views

How to intergrate Etherum Wallets for my business [closed]

What will it take intergrate Etherum Wallets for all my customers. I run a business and would love my customers to be able to create their own Etherum Wallets to receive and send.
0
votes
1answer
8 views

Block.timestamp returning multiple values

I have a function inside my smart contract that fetches the timestamp of the block it's in: function getTime() public returns (uint256 time){ return block.timestamp;; } According to how I ...
0
votes
1answer
26 views

Web3 1.2.6 appears to ignore require in view function

Given the following function: function checkLock() external view returns (bool) { require( address(this) == IERC721(_nftRegistryAddress).ownerOf(_tokenId), "[...
0
votes
1answer
19 views

Gnosis multisig wallet, Error in call method

This is an external function which will be called when a transaction have enough number of confirmations. function external_call(address destination, uint value, uint dataLength, bytes data) ...
0
votes
1answer
15 views

Gnosis multisig Wallet

This is a function that returns an array of addresses that confirmed for a transactionId. mapping (uint => Transaction) public transactions; mapping (uint => mapping (address => bool)...
0
votes
1answer
31 views

I'm getting “Cross-Origin Request Blocked” error

I'm getting this error: Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost:8545/. (Reason: CORS request did not succeed). I'm aware ...
0
votes
1answer
55 views

Function modifier effect on return value

Having the following code pragma solidity ^0.6.4; contract TestModifier { mapping (address => bool) public authorities; mapping (address => address) public authorized; modifier ...
0
votes
1answer
26 views

Returned error: gas required exceeds allowance (8000000) or always failing transaction

I am running private block chain using geth, Here is my geth command : geth --datadir $ethereum_home/chaindata --networkid 45683 --verbosity 3 --rpc --port 30304 --rpcport 8545 --rpcaddr "0.0....
0
votes
1answer
17 views

Best way to loop through mapping

I have a voting contract and I am trying to find out the best way to get the winner key. Here is my code. pragma solidity ^0.4.25; contract Voting { mapping (int => uint8) public votesReceived;...
0
votes
1answer
17 views

How does the zero account transfer tokens?

In this transaction, the from address is withdrawing Dai from the Compound contract. What puzzles me is why the zero address(0x00...) can transfer Dai to the from address.
0
votes
1answer
15 views

How to include constructor arguments in bytecode for smart contract deployment in genesis block?

Please excuse if the title is not perfectly accurate but I had a hard time fitting my problem into 1 question. If you have a better title please feel free to suggest it and i will edit it. I want to "...
1
vote
1answer
15 views

How to pass constructor parameters to solc?

I'm trying to compile a Smart Contract to bytecode using solc. I'm on a Ubuntu VM so I have to rely on a simple-to-install cmd line application. Compilation works fine but it seems like I can't pass ...
0
votes
0answers
38 views

Why error 'Fail with error 'Storage: Unpermissioned operator <0xc3d5d60630bc63eb1a07228cc5028cada1cc4c7b>' arises?

I wants to deposit & withdrawal DAI (https://kovan.etherscan.io/address/0xc4375b7de8af5a38a93548eb8453a498222c4ff2) to SOLO Margin(dydx) smart Contract at Kovan testnet (https://kovan.etherscan....
0
votes
2answers
24 views

How to deploy multiple compiled solidity with web3?

So I have this codes const MultiSigWalletFactory = fs.readFileSync(path.resolve(__dirname, "MultiSigWalletFactory.sol"), "utf8"); const Factory = fs.readFileSync(path.resolve(__dirname, "Factory....
0
votes
2answers
19 views

How to prevent someone to replace our smart contract

I'm still learning to develop dApp and currently, I conduct some testing on my dApp. I found out that someone who is part of the blockchain network (miner and node) can replace our deployed smart ...
-1
votes
1answer
25 views

Is it possible to see a token contract release date in Solidity?

I would like to make a contract where people can deposit tokens that were created before the end of 2019. In other words, I need to check the date the contact was released before accepting tokens that ...
2
votes
1answer
16 views

How do I set the constructor arguments when deploying using OpenZeppelin CLI?

My Token contract compiles fine using solidity 0.5.0: import "/Users/lennard/Desktop/GGToken/node_modules/@openzeppelin/contracts/token/ERC20/ERC20Detailed.sol"; import "/Users/lennard/Desktop/...
0
votes
1answer
18 views

File import callback not supported in solcjs

Running E:\projects\Greeter-Contract-master\contracts>solcjs --abi Greeter.sol gives: Greeter.sol:3:1: ParserError: Source "contracts/Mortal.sol" not found: File import callback not supported ...
1
vote
1answer
25 views

What should be the limit for miner to mine a block

I am trying to run my smart contract in remix ide, below is my smart contract code: pragma solidity >=0.4.17 <0.7.0; pragma experimental ABIEncoderV2; contract Department{ struct Employee{ ...
0
votes
2answers
23 views

mapp values do not upadte when calling other functions after populating the map

I am using react as my front end to call functions from smart contract . this is the front end where i call the functions. However, after calling the first function which populates the map I then ...
0
votes
1answer
22 views

Factory contract to clone existing contracts

I am researching about Factory contract to clone existing contracts, First is the implementation present at https://github.com/optionality/clone-factory/blob/master/contracts/CloneFactory.sol. I don't ...
1
vote
1answer
26 views

Looking for code that makes this contract pay out dividends

I have used OpenZeppelin contracts to create a token in Remix that I can mint and send around: pragma solidity ^0.5.0; import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v2.5.0/...
1
vote
1answer
14 views

Error: Invalid bytes6 value

I'm trying to create a TicketPurchaser application. Here is the whole code for the smart contract, although I think the problem I'm asking about is a type error, most of the code is not important. ...
0
votes
1answer
15 views

Does returning “false” prevent bool function from further execution in Solidity?

example: function proceed() returns (bool success) { if (msg.sender != owner) return false; return important_function(); } So important_function shouldn't be reached if msg.sender isn'...
1
vote
1answer
52 views

How to reset the length of array in solidity v6.0?

The code gives the following error in solidity v0.6 compiler but works fine with compiler v0.5: TypeError: Member "length" is read-only and cannot be used to resize arrays. nodes.length = 0; pragma ...
1
vote
1answer
22 views

Value of emitted events in App.js

Actually in my App.js I have called my contract function like this: [ this.state.swapcontract.methods.sendFunds(address).send({ from: this.state.account , value:amount}) ] The function is called ...
1
vote
1answer
25 views

converting keccak from old version: pragma solidity 0.4.19; [duplicate]

I am trying to compile following code: pragma solidity 0.5.9; contract test{ //https://github.com/ethereum/solidity/issues/3469 address payable owner; mapping (address => bool) pd; uint public sS;...
1
vote
1answer
22 views

ERC-20 Token Smart Contract Redeployment

Hello everyone am wondering how can someone redeploy ERC-20 Token Smart contract thats already deployed? I have already deployed few contracts both on Ropsten Test Network and on Main ETH Network ...
0
votes
1answer
19 views

How to safeguard a different token stored in an ERC20 contract from unwanted withdrawal?

If I want to store say a popular ERC20 (e.g. BNB) in my new ERC20 contract, how do I prevent someone from making unauthorized withdrawal of these BNBs from my contract account ? Is it possible that a ...
0
votes
2answers
30 views

Solidity Puzzle! How to get position in a list without looping over unbounded mapping?

Consider I mint 10 CryptoDoggy NFTs, each with an incrementing ID, starting at 0. I also have a uint => uint mapping, which records the position of the NFT using its ID as a key. Initially, its ...
1
vote
1answer
29 views

How to create a token exchange for private blockchain?

I have requirement to create a exchange for my private blockchain tokens, where registered user can buy and sell tokens, and token price goes up and down on demand and supply. I have searched bit, ...
1
vote
1answer
35 views

How to create transaction data for sending ethereum from multiSig contract to account with Web3.js v1.2.1

I am using a standard MultiSigWallet contract. My goal is to create the data parameter with web3, which is used in executeTransaction / external_call (bytes memory data). The transaction should send ...
1
vote
1answer
25 views

How can I convert an element of a byte32 array to number?

The array contains an SHA256 hash. I want to add up 2 hexadecimal values, and later multiply them by 1.125 (only keeping integer). The resulted number would represent an alphanumerical character, it ...
1
vote
1answer
24 views

Error: you must provide the json interface of the contract when instantiating a contract object

That's the error that occurs when I try to test my contract. Can someone tell me what the problem is? That's the code for the test: const assert = require('assert'); const fs = require('fs'); const ...
3
votes
2answers
19 views

Set and delete storage variable in same tx

I did some poking around and didn't see an answer... and I figure someone knows this off the top of their head. Question: what is the gas cost associated with setting and deleting a storage variable ...
1
vote
1answer
31 views

When testing a contract, NodeJS returns: “SyntaxError: Unexpected token u in JSON at position 0”

My NodeJS script gives me this error: 1)"before each" hook for "deploy a factory and a lottery" SyntaxError: Unexpected token u in JSON at position 0 at JSON.parse((anonymous)) at Context.(anonymous) ...
1
vote
1answer
9 views

Puzzle- how to implement simple savings pool (via cDai) without iterating over unbounded loops?

Consider this example of a very simple savings contract, where users send Dai, which the contract converts to cDai. At any time users are free to withdraw their share of the accrued interest. I cannot ...
3
votes
1answer
151 views

How can I use the mathematical constant e in Solidity?

I want to calculate a mathematical function which will use the mathematical constant e, and I don't know how to use e, like Math.e.
1
vote
1answer
28 views

Which token standard should be use to create different tokens for different users?

I have read several differences between fungible and non fungible tokens. It cleared my few doubts though, I have few more remaining. I have requirement to create a platform on which users can ...
1
vote
0answers
18 views

Failed to create genesis block [closed]

I tried creating genesis block. I have created a directory to store the chaindata. But on initializing genesis.json file I am getting this error: invalid genesis file:invalid character '<' ...
1
vote
0answers
28 views

Ethereum DApp example? [closed]

I am finding for the open source ethereum dapp example. Could anyone recommend me any dapp that is fully operable by my own? Thanks.
1
vote
1answer
17 views

TypeError: Member “editor” not found or not visible after argument-dependent lookup in struct PrivateSmartContract.BuildingRental storage ref

I want to store user's wallet address array as editor's address so i created struct with array like following pragma solidity >=0.4.0 <0.7.0; pragma experimental ABIEncoderV2; contract ...

1
2 3 4 5
166