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
0answers
20 views

Is there a way to know if a Solidity method will revert?

I have some solidity methods in my contract, and when i make a send in web3.js i would like to know if there is a way to know if the functions are going to revert by using call. Per-example , in ...
2
votes
1answer
18 views

What is the purpose of a `// dev:` comment after a revert or require statement?

What does it mean when a Solidity contract includes a comment starting with // dev: after a revert or require statement? For example: contract Example { function greet(){ revert(); // ...
0
votes
1answer
20 views

How to use initialize a bytes array with abi data?

To initialize a bytes array with the bool value True encoded as ABI data, I'm attempting to do it like this: bytes memory arr = '0x0000000000000000000000000000000000000000000000000000000000000001'; ...
1
vote
1answer
25 views

Why doesn't solidity have 'sizeof' keyword like python have?

I want to know how can I use sizeof keyword. is it reserved keyword? i found it in the solidity documentation.
3
votes
1answer
47 views

Do we have 'null' keyword in solidity?

Like other languages , Does solidity supports 'Null' keyword.
0
votes
1answer
20 views

Import errors when compiling contracts using truffle

Please help me understand this error `**enter code here**`No build configuration found. Preparing to compile contracts. Compiling your contracts... =========================== Error: Could not find ...
2
votes
1answer
36 views

Why doesn't the solidity perform rounding off to nearest whole number

The function getInt() is always returning more than 1. Shouldn't it do a round off for values less than 0.5 and return 0 ? Please check the image and let me know, if I am doing something incorrectly ...
1
vote
1answer
30 views

Is there an “after” keyword in Solidity?

This is to avoid any further question in the future.
4
votes
2answers
92 views

Graph traversals on Ethereum, at scale

I read the Efficient Solidity storage pattern for a directional weighted graph thread, but that deals with storing graphs. I'm interested in techniques for how to traverse graphs in Solidity, at scale....
0
votes
1answer
32 views

Is there an “in” keyword in Solidity similar to Python? [duplicate]

I understand that "in" is a reserved keyword in the Solidity language (for now) but can it be used like the "in" keyword is used in the Python language? That is can it be used to find a specific value ...
0
votes
1answer
39 views

How to implement ether transfer from one EOA to another using a contract?

I am working on a private development network set up with geth with PoA consensus. Everything is working well from the geth console. I have written a Solidity contract to initiate some ether transfers ...
2
votes
0answers
43 views

SPDX license when importing other people's contracts

Since Solidity 0.6.8, the compiler started throwing warnings if a contract isn't annotated with a SPDX license identifier: // SPDX-License-Identifier: MIT contract MyContract { ... } Now, there'...
2
votes
0answers
27 views

Does Ethereum support just bilinear pairing calculation not the pairing check?

I need to implement bilinear pairing calculation on my contract. Specifically, I have uploaded some parameters and need other users to calculate the pairing for me and I will pay for them if their ...
0
votes
1answer
20 views

Paying for a transaction that will happen later

I have a voting contract that opens and closes every 5 minutes. I don't want the owner to have two transactions for open and close. Is there a way I can have the owner pay for the close transaction ...
0
votes
0answers
22 views

Can we determine gas price for a function without deploying it? [duplicate]

I want to store a document hash on an Ethereum network. I have two options. 1st one is to send the transaction directly through a node js application with input field as the document hash ie, ...
2
votes
1answer
31 views

Is “type” a reserved keyword in Solidity?

If I define the following struct like this: struct MyStruct { uint256 type; } The Solidity compiler throws an error: Expected identifier but got 'type' I checked to have no mistake in my code ...
0
votes
1answer
35 views

ParserError: Expected primary expression - address payable - payable()

I'm trying to get myself familiarized with ethereum. So I was going through a repo, and tried to rum the code : function transferFundOnResolve(uint cid) private { // Could also be used: ...
0
votes
1answer
41 views

Truffle Contract and nodejs

I want to send a data to a function created in a smart contract. function notarizeHash(uint256 id, bytes32 documentHash) public onlyOwner noHashExistsYet(id) { hashesById[id] = documentHash; ...
2
votes
1answer
25 views

Visual Studio Code's Solidity extension shows unecessary warnings/errors

I am using Juan Blanco's Solidity extension for VSC. I am noticing it is showing just too many warnings everywhere, including the OpenZeppelin contracts in the node_modules folder. Is there any ...
0
votes
1answer
16 views

Was the function called before from a specific address?

Consider a function definition as below - function checkForUpvote() external returns(bool){ Here I would first like to check, if the external account invoking this function : has invoked this ...
1
vote
1answer
23 views

Why does Solidity not use the years keyword?

Solidity has keywords like seconds, minutes, hours, days and weeks that are used to specify units of time. Why do they not have years?
0
votes
1answer
34 views

address(this) in solidity is returning wrong contract address

This is my cantract code which I was using in truffle pragma solidity 0.5.16; contract Test { function getAdd() public view returns(address){ address add = address(this); return ...
0
votes
0answers
44 views

My is metamask returning RPC Error: Error: [ethjs-rpc] rpc error with payload, metamask shows failed [object, object]

My metamask shows ALERT: Transaction Error. Exception thrown in contract code. When I am about to transfer using truffle, open zeppelin and ganache on localhost:7545 after confirming the transaction ...
1
vote
1answer
30 views

How to get the decimals of ERC20 Token in smart contract

I have a smart contract which operates with an "external" ERC20 Token. For some calculations I need to access the decimal() function of the ERC20 Token. In my contract I have the following line: ...
0
votes
0answers
43 views

Why is the compiler unable to generate Contract ByteCode and ABI when I try to Verify & Publish my contract?

Another dev no longer connected to our project deployed this contract, and I'm trying to Verify & Publish it on Etherscan now. What am I doing wrong? I do know that the dev who built this used ...
0
votes
1answer
19 views

TypeError: Operator == not compatible with types bool and uint256

I am receiving the error: 'TypeError: Operator == not compatible with types bool and uint256' my code is: if (orderedScreening[0]/4 == orderedScreening[1]/4 == orderedScreening[2]/4 == ...
0
votes
0answers
16 views

How to access event log data using web3j

In my smart contract, I have defined following event: event logDomainFilter(uint128 indexed _campaignId, uint128 indexed _flightId, uint128 indexed _siteId, string _siteName, string _whiteListDomains,...
0
votes
0answers
16 views

Ethereum Remix : Console trow an error: 'unexpected token: identifier'

I'm follow this tutorial to learn about smart contract on Ethereum.This is the pieces of code I already made. pragma solidity ^0.4.24; // Naming the contract contract MyContract { string value; ...
1
vote
1answer
28 views

Web3.py: ValueError: Could not format value when trying to deploy smart contract bytecode from Truffle

I have a working solidity contract which compiles and gets deployed successfully by both truffle and web3.js + metamask. Importing the very same contract into python and deploying it using web3.py (...
0
votes
0answers
10 views

Implementation Question for Licence Token

I am currently working on the idea of using token as licences for digital products. I am offering different documents and books in pdf format and want people to be able to buy them with ETH o.ä.. I ...
3
votes
2answers
45 views

Can someone please explain how address(uint160(bytes20(b))) works differently than address(uint160(uint256(b)))?

Please explain how address(uint160(bytes20(b))) works differently than address(uint160(uint256(b))) when converting a type that uses a larger byte size then address, for example bytes32, then the ...
0
votes
1answer
34 views

Error in smart contract solidity [closed]

Hello i have some problem when i compile my smart contract with truffle i use the network of truffle develop Truffle v5.1.14-nodeLTS.0 (core: 5.1.13) Solidity - ^0.4.0 (solc-js) Node v13.1.0 Web3....
1
vote
1answer
32 views

Someone Please Explain this “The concept of payable and non-payable addresses only exists at compile time not after the contract is compiled” [duplicate]

Actually I was reading this Answer https://ethereum.stackexchange.com/a/64109/55286 . And this person says The concept of payable and non-payable addresses only exists in the Solidity type system at ...
2
votes
1answer
77 views

How to pass 0 length array as parameter on EtherScan contract editor

suppose one of the function input parameter is bool[] testInput sometimes I want to pass 0 length array like this => [] instead of this => [true,false,true], how does it possible with etherscan.io. ...
0
votes
0answers
16 views

function not found or not visible

I am trying to test different ways of invoking methods of other contract i.e. through an object (works) and through the address (not working). pragma solidity ^0.5.1; contract test1 { function f(...
0
votes
0answers
21 views

How to filter an indexed event parameter using web3j?

I am planning to use ethereum logs as a data storage on my private blockchain. I have defined event in my contract like this: event logDomainFilter(uint128 indexed _campaignId, uint128 indexed ...
0
votes
0answers
43 views

how to match python list and integer to solidity smart contract uint256[] and uint256. web3.py

web3.exceptions.ValidationError: Could not identify the intended function with name `storeSurvey`, positional argument(s) of type `(<class 'int'>, <class 'list'>, <class 'numpy.ndarray'&...
0
votes
0answers
26 views

MetaMask - RPC Error: Error: [ethjs-rpc] rpc error with payload [obejct Object

I am trying to sign transactions using certify_send() function to a smart contract deployed to my private ethereum blockchain but I keep getting this error after I approve in MetaMask MetaMask - RPC ...
0
votes
1answer
41 views

Abstract contracts cannot be initialised, can they?

As of v0.6, solidity introduced abstract contracts. Do they behave just like in all other languages - that is, they can't be initialised, can they?
0
votes
0answers
13 views

Return parameters is not getting translated to java using web3j cli

When using newest version of solidity compiler "pragma" solidity ^0.6.9 The program compilation is successful. I'm just using this code Contract Counter{ unit public Variable_name; ...
0
votes
1answer
18 views

Ethereum token not logging txs

I'm back again with another token question. If you have seen my previous posts, they have all been about merged mining and prevented eth burn, etc etc. I am in the process of creating V2 of a token I ...
0
votes
0answers
12 views

1) How can we use Ethereum Alarm Clock for Scheduling a txn in Private network(using geth/ganache)

2) Can we schedule a txn in such a manner that it could be executed multiple times in a particular time window?(For eg: if we need to schedule the txn everyday 5.00 pm) or the EAC has the option of ...
0
votes
2answers
99 views

How do I check for the existence of a function in Solidity when I have an address that might implement that function?

If I'm writing an Ethereum smart contract in Solidity and I know I have an ERC20 address variable (let's call it some_erc20_token), but I don't know whether this address implements the interface of an ...
0
votes
2answers
28 views

Are events collected in Web3js asynchronously?

I am collecting a set of previously generated events, based on certain filters/test, and trying to display them on my HTML page. The code I am using to fetch the events is as follows: var eventList = ...
3
votes
1answer
29 views

Ethereum Signing using HSM

I tried signing a Message using the SHA256withECDSA algorithm . It gives a different signed(r,s) output everytime. When i try to recover the address using the ecrevover method .it gives me a different ...
0
votes
0answers
22 views

Can you call a contract's (C) function with the msg.sender value of another contract (B) while originating the transaction from a third contract (A)?

If there exists a proxy/implementation system (two contract system) where Contract C (the proxy) only accepts calls from Contract B (Contract B is the owner of Contract C via {owner = msg.sender} in ...
2
votes
0answers
22 views

unable to veriify a signed message in solidity

behaviour of web3py and solidity. Samples: ## First in web3py sig = Web3.soliditySha3( [uint256], [tokens] ) ## used below also output: HexBytes('...
0
votes
0answers
24 views

Gas-efficient string concatenation

My use-case requires that I feed my contract with a long string (Base64 data), which requires to split it and send it over several transactions so as to not reach gas limit. Then the contract rebuilds ...
0
votes
0answers
39 views

Convert address to bytes8

I want to convert address to bytes8, but I only managed to convert address to bytes this way: bytes memory shortAddress = new bytes(8); for(uint i = 0; i < 8; i++) { shortAddress[i] = byte(uint8(...
0
votes
1answer
37 views

Compiled solidity contract run out of gas on deployment

I have a solidity contract that compiles ok (0.5.1 compiler version), but it runs out of gas if I deploy the whole of it. If I comment some of the external methods of the contract, it compiles and ...

1
3 4
5
6 7
175