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
2
votes
0answers
14 views

Why does Ethereum use JSON-RPC and not gRPC?

I am fairly new to networking protocols especially JSON-RPC and gRPC as they are not nearly as common in web development as REST. I was reading around and seems like gRPC generally performs better. So ...
0
votes
1answer
12 views

How to call sha256 in assembly

I wanna compute sha256 in Solidity Assembly for hash of getting bytes slice.
0
votes
0answers
14 views

How to send an array of structs from web3js to solidity contract?

I am getting an error when passing (javascript array of objects) from web3js, To solidity function that takes (array of structs) as a parameter. could you help me? below is the code and the error /...
0
votes
1answer
21 views

Multiple transfers, one smart contract

I have the following function in my contract: function AcceptOffer() public payable { if ( msg.sender != InstanceOwner ) { revert("You are not the owner of this ...
2
votes
1answer
19 views

How to properly define an interface in Solidity 0.6?

One of the breaking changes of solidity 0.5 was making explicit function visibility mandatory, hence all interface functions must be defined as external today. In solidity 0.6, there seems to be two ...
0
votes
1answer
19 views

How to find the address of the contract owner?

I'm under the impression that the owner of the contract is simply referred to as accounts[0] in Truffle's testing environment, but I'm getting the error by the modifier that the caller of a certain ...
-2
votes
0answers
8 views

interesting smart contract on ethereum. What about a distributor contract.? [closed]

came up with a funny idea. Make a smart contract that would distribute funds automatically between all addresses that sent transactions to it. An approximate algorithm is this: when an incoming ...
1
vote
0answers
14 views

Contract not returning error to React Interface

I have a contract which I've tested with Mocha and Remix and is working just fine. The problem is when I'm running it with my React Interface. When I call a function in my solidity contract that ...
0
votes
0answers
11 views

how to register a property(house) for sell using ERC721 standard?

Is it possible to register a property(house) for sell using ERC721 standard? the contract will include all the necessary details of the property and also include a buying request. please share all ...
0
votes
1answer
11 views

Reference Smart Contract Address in Smart Contract

Is there a way to know the address of the smart contract you are writing before deploying it? Or somehow reference the smart contract address in the smart contract?
0
votes
1answer
14 views

Enforcing a limit on ERC721 tokens held by an account

We are providing a Gnosis multisig wallets to our users and a market place where users can purchase/sell/transfer ERC721 tokens with other users. The ERC721 contract will also have a Blacklist ...
4
votes
1answer
107 views

Underhanded Solidity: Exploiting multiple inheritance

In an article by Steve Marx (on Medium.com), the author argues against using inheritance in solidity not only because of harder readability of a Smart Contract, but also because it can be exploited in ...
0
votes
0answers
23 views

How do I inject Web3 into Remix IDE?

when going on to the remix IDE, i get the error No injected Web3 provider found. Make sure your provider (e.g. MetaMask) is active and running (when recently activated you may have to reload the page)...
1
vote
0answers
27 views

go-ethereum: Return data from contract function

I have a smart contract written in solidity. I deployed the contract to my Ganache network and I can interact with it via go-ethereum using stubs generated by abigen. My function returns a uint256, ...
3
votes
0answers
32 views

Unit testing a Solidity Library function with a struct memory argument

I am trying to unit test a Solidity Library contract function using truffle and web3. My simplified Library contract looks like this: pragma solidity >=0.5.16; pragma experimental ABIEncoderV2; ...
1
vote
1answer
15 views

transfer hash verification on contract side

I want to verify if message-hash has a particular contract method. Like below web3 code generates a rawTransaction having,messageHash,v, r, s, rawTransaction let rawTransaction = { 'from': ...
2
votes
1answer
25 views

Destroy smart contract and collect its funds

I'm quite new at smart contracts/Solidity, which I'm learning for a postgraduate course. In one of the assignments, we have to implement a short example of dutch auction (wiki link). Now my question ...
0
votes
1answer
14 views

Smart contract function not returning expected output

I'm quite new at this and I'm learning both Solidity, Javascript and React to play around with smart contracts. My contract ran well in Remix and in a local test net. I ran a bunch of tests using ...
0
votes
0answers
14 views

How to make my contract balance as private in Ethereum?

Suppose there are two contracts, A and B. Obviously, balance of A is public and B can read it with address_of_A.balance. Is there a way to make balance of A as a private data and B can't read it with ...
0
votes
0answers
10 views

Remix IDE not showing return value

Using the following code as an example: // SPDX-License-Identifier: MIT pragma solidity ^0.5.0; contract SimpleStorage { event StorageSet(string _message); uint256 public storedData; ...
0
votes
1answer
17 views

How to initialize address[] array with values

Is there any shorter way to do the following? address[] memory myArray = new address[](2); myArray[0] = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2; myArray[1] = ...
-1
votes
1answer
12 views

Trying to compile running: 'node compile.js', but get error: “assert.js:399 throw err;” [Udemy 'Complete Developers Guide' Course]

This is my hands on contract with this Udemy Course - Ethereum-and-solidity-the-complete-developers-guide This is the contract file, which contains two contracts - Campaign and FactoryCampaign. I ...
0
votes
1answer
29 views

Getting undefined for the length of the dynamic array

I'm getting undefined for the length of multiSig dynimic array, or votes in testing, no matter how many items are pushed into the array. FlightSuretyData.sol address[] multiSig = new address[](0);...
1
vote
0answers
17 views

Are there well-solved patterns and practices for handling errors in Solidity?

The approach I'm taking with this question is similar to Are there well-solved and simple storage patterns for Solidity?. Are there any known, battle-tested practices for how to deal with errors in ...
0
votes
0answers
13 views

Data location must be “calldata” for parameter in external function,

I'm getting the following error: Data location must be "calldata" for parameter in external function, but "memory" was given. for the following function: function _registerAirline(address ...
0
votes
0answers
10 views

importing a big standard contract

I am following a tutorial to use oracle from Provable, so I have to import "https://github.com/provable-things/ethereum-api/blob/master/provableAPI_0.6.sol". I notice that the contract is very big but ...
0
votes
1answer
15 views

How to delete an element of array in efficient manner?

pragma solidity ^0.4.24; contract test{ uint[] public array = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]; function removewithgap(uint index) returns(uint[]) { if (index >= array.length) ...
0
votes
1answer
13 views

How to reverse byte order in uint256 or bytes32?

Need to convert BigEndian to LittleEndian or vice versa.
0
votes
1answer
13 views

Nested Structs with Mappings Inside

I have the following code: // SPDX-License-Identifier: MIT pragma solidity >=0.4.22 <0.7.0; pragma experimental ABIEncoderV2; contract VenueRegistry{ struct Queue{ uint head; ...
0
votes
0answers
16 views

Getting the “VM Exception while processing transaction: revert” error for a pay() function

I'm getting the following error during the testing in Truffle: Error: Returned error: VM Exception while processing transaction: revert It simply says "revert" without the contingency message, ...
0
votes
0answers
15 views

How does EVM search in the storage?

I am reading this article to understand the storage in Solidity/EVM https://programtheblockchain.com/posts/2018/03/09/understanding-ethereum-smart-contract-storage/ It says that each smart contract ...
0
votes
1answer
22 views

Data location can only be specified for array, struct or mapping types, but “memory” was given

I am new to solidity. I was trying to compile the following code in chrome browser with Remix. I am getting the following error "Data location can only be specified for array, struct or mapping types, ...
0
votes
1answer
14 views

Deploying a smart contract using transaction manager in web3j

I am new to web3j and smart contract deployment. Consider a scenario where a user is too scared to give his wallet credential file or username/password or private key in a piece of code(the code is ...
0
votes
0answers
26 views

Accessing modifier of another smart contract - Role Based Access Control

I am trying to create a simple role based access control system for the contracts I have created. I have two smart contracts, one named Users that stores all of the users details as well as the type ...
1
vote
0answers
24 views

How to compute pairing in a smart contract

I am working on the elliptic curve and pairing stuff in Ethereum smart contract. How can I compute pairing such e(p1,p2)? I know that we have a pre-compile pairing check in Ethereum client which is ...
0
votes
1answer
17 views

why to use ERC165 standard?

when implementing ERC721, why it is necessary to use ERC165 standard? `pragma solidity ^0.6.6; interface ERC165 { function supportsInterface(bytes4 interfaceID) external view returns (...
0
votes
1answer
13 views

Issues with using/installing python solidity parser

I am trying to install and use python solidity parser by ConsenSys I keep on getting the following error File "<stdin>", line 1, in <module> File "/home/seed/.local/lib/python3.5/site-...
0
votes
0answers
32 views

if “address public x = tx.origin”, why does “require (tx.origin == x”) work and "require (tx.origin==tx.origin) not

Below is a contract that i have commented on, hoping to understand the logic of the arguments. Below in bold is the question in question. The .sol currently works fine. pragma solidity ^0.5.11; ...
0
votes
1answer
15 views

How to efficiently query custom token

I have a smart contract with a custom token which holds some data. The Token data is defined in a struct and stored in an array: struct Token { string text; uint256 value; } Token[] public ...
0
votes
0answers
27 views

How to separately optimize bytecode?

This question is regarding the bytecode-optimizer of the solidity-compiler, not the yul-optimizer: Is there any way to separately optimize bytecode? Normally the solidity-compiler optimizes the ...
0
votes
1answer
20 views

What is the has() function in Solidity?

What is the has() function in Solidity? struct Role { mapping (address => bool) bearer; } function add(Role storage role, address account) internal { require(account != address(0), "...
1
vote
1answer
21 views

Gas price data from GETH

I am able to get gas price data as follows from some oracles (i.e., ethgasstation.info, etherscan.io): { "fast":50.0, "fastest":200.0, "safeLow":10.0, "average":20.0, "block_time":13....
0
votes
2answers
32 views

How can I get the revert reason of a call in Solidity so that I can use it in the same on-chain transaction?

I want to get the revert reason of a failed call and then use that revert reason in the same on-chain transaction. Is this possible?
0
votes
1answer
21 views

Buy tokens form other smart contract using interface

I have two separate contracts, let's say Token and BuyFrom. pragma solidity >=0.4.22 <0.7.0; interface InterfaceToken { function invest(address contributor) external payable; } contract ...
0
votes
1answer
27 views

Problem: Payment between smart contracts without reducing the balance of the sender contract

I work on Truffle. I have two smart contracts A and B. Codes of them are same. A should transfer some ether to B and store some information about this payment. I funded A with METAMASK. But, whenever ...
0
votes
0answers
11 views

How do I get a structure of a mapping inside a structure?

So. I started using too many mappings. Now I'm not sure how to get the information on the front: struct Demand{ uint remuneration; uint delay; uint deadline; string description; ...
0
votes
0answers
8 views

openzeppelin sdk deploy: missing contracts

I'm trying to deploy an Initializable contract using oz deploy but when it comes to pick it, it does not appear. My contract is a factory contract and also a GSNRecipient but it shouldn't make any ...
0
votes
1answer
16 views

How does explicit type conversion to a contract work?

Following is an example from the Solidity doc, but I have three questions: // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.4.16 <0.7.0; contract OwnedToken { TokenCreator creator; ...
0
votes
1answer
10 views

Why token value is getting changed on Ethereum?

I have created ERC20 token with 18 decimals. From web3 (application front end) when I transfer 100 tokens, on etherscan it shows 0.0000000000000001 . When I call to get the balance then on UI it ...
0
votes
0answers
16 views

Is it ok to *not* zero out old mapping keys to save gas?

I have an escrow from which addresses can withdraw from after a timelock. Each address (1) has a balance, (2) can request to withdraw from at any time, and (3) actually withdraw from at a later date. ...

1
2 3 4 5
170