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
4 views

Truffle - deploy and interact with a contract locally from a script

I have created a contract, wrote a migration and a test. When I run truffle test the contract is deployed locally and then the tests are run against it. All is working fine. I also added a function to ...
1
vote
1answer
24 views

Node version upgrade for contract deployment throws error

I wrote a solidity contract using version 0.4.24 using OpenZeppline-solidity version 1.12.0. This used to deploy using the Nodejs version 8.12. The Nodejs version 8 is no longer being maintained from ...
0
votes
0answers
20 views

Is first call to oraclize query free in mainnet, as in testnet?

We were trying to include oraclize query to get price feed in one our contracts, as of now we have observed that the first oraclize is free in kovan. Does same applies for mainnet or else we has to ...
0
votes
1answer
10 views

Why is the receive () external payable not acting as a fallback?

I have this simple code in remix.ethereum pragma solidity ^0.6.1; contract SimpleWallet { address owner; constructor() public { owner = msg.sender; } modifier ...
0
votes
1answer
20 views

Cannot read data from smart Contract with web3 js

Im having trouble reading data from a smart contract I have following js script right here: (bcc-js.js) var contract_address = "0x88e304D8638c31DaC3336917bbE4A152927198D8"; var contract_abi =...
1
vote
0answers
12 views

What is the method to send a transaction with data from solidity?

Sorry for the noob question, but Im trying to understand some definitions and clarify the limits between solidity, web3, etc. I have obtained a tx looking like the following from the 0x API: b'{"...
0
votes
1answer
18 views

What does this piece of code mean?

Can you tell me what this piece of solidity code means please? uint number = uint(block.blockhash(block.number - 1)) % 37; Thank you Take care Pierre
1
vote
0answers
32 views

Execution erorr: Invalid opcode on estimateGas | Possible unhandled promise rejection

pragma solidity ^0.5.0; I get invalid opcode error when trying to estimate gas needed for my transaction from react-native using the following line of code: const gasAmount = await contract.methods ...
1
vote
1answer
28 views

Recovered address not matching signer address (using ethers)

Below is a simple signature verification flow I wrote, along with a test case with Buidler (all mainly to learn how to verify signatures in a Solidity smart contract). The problem is that the address ...
0
votes
0answers
22 views

Why are there errors in the code I copied in a book called Ethereum smart contracts development”

pragma solidity ^0.4.11; contract simpleVotingDapp { /* The key of the mapping is candidate name stored as type bytes32 and value is an unsigned integer to store the vote count */ mapping (bytes32 =&...
0
votes
1answer
34 views

How to test abstract contracts using truffle?

Is it possible to test abstract contract using truffle? If yes, how I can to do it?
2
votes
1answer
29 views

how to call “selfdestruct” if not written in contract, as documentation says its possible

as mentioned in documentation "Even if a contract’s code does not contain a call to selfdestruct, it can still perform that operation using delegatecall or callcode." so my question is how ...
0
votes
0answers
13 views

Why am I receiving the error when running “npm run start” for the client folder inside the truffle react box? [closed]

I am getting the following error when I run npm run start for the clients folder inside the truffle react box. Here's the error:- There might be a problem with the project dependency tree. It is ...
1
vote
0answers
17 views

Truffle test: how to get the block number of deployed contract?

In my test I would like to get the block or block number of when the contract was deployed. const instance = await MyContract.deployed() const contractDeploymentBlockNumber = await instance.?
1
vote
1answer
12 views

Library calls fail depending on compiler version?

I'm trying to deploy my library and call it afterwards with the specific address. While testing this I encountered that the behavior changed over the course of compilers. I tried to follow How to call ...
0
votes
0answers
24 views

How to authenticate user details in smart contract? [closed]

I am building a login system in my dapp for which i have to check the details with already registered users .I tried it by getting user details in frontend and then authenticate it but i think it is ...
0
votes
1answer
45 views

Parse error:expected primary expression on remix. is there any way to fix this? [closed]

function retrieveEHRs(string stringToBytes32, string retrieve_name, address userPK,string storageName, address AreaID, address PatientID, string Hash_value) onlyAdminp public{ bytes32 key=...
1
vote
1answer
32 views

Finding values within an Array/Mapping based off min and max values

I want a user to be able to place a bet on some number, between a range of numbers. So the user wants to place a bet on the numbers 50-500. Then there is a function that sees if the number has been ...
0
votes
0answers
19 views

Public boolean getter failing [closed]

I added a public bool exists field in a contract to check if it truly exists in my mapping (address => contractType). However, the contract always seems to fail when calling the exists getter. // ...
0
votes
0answers
13 views

Unbounded loop solidity internals

Under the hood, what happens in an unbounded loop? let's say I'm trying to send tokens to an infinite amount of addresses and end up with an out of gas error. Will the function which executes the ...
0
votes
1answer
17 views

How can i create more that one node for test purposes?

I really need to have more than one node to test my smart contract. I'm using remix and i also installed ganache, however, ganache doesn't allow me to have more than one node as I hoped for... I have ...
0
votes
0answers
11 views

Smart Contract - Simple to Dutch Auction [closed]

I am looking for a Dutch Auction smart contract where we use simple auction and convert it into a dutch auction. I have added simple auction but I want to know how to convert it to dutch auction ...
0
votes
1answer
15 views

How to determine the return address when we use CALL opcode?

I'm try to understand each opcode defined in Ethereum Virtual Machine. As for the opcode 'CALL' I find that it needs 7 arguments from the stack: gas, addr, value, argument addr, argument offset, ...
0
votes
0answers
10 views

What would be good result measures in Ethereum

I'm thinking of a way to present relevant results measures for my blockchain. I can see how for hyperledger is interesting to present (transactions per second x block size) or (latency x block size). ...
0
votes
1answer
14 views

Function not returning address when using web3 provider

I have a contract that works fine when only using remix. I needed to test the block size and block number. here someone suggested me to use ganache which I did but now I don't get the output I'm ...
0
votes
1answer
20 views

Call private internal function from another contract

Is it possible for me to call from a contract B, that has an instance of A, a private or internal function of contract A?
0
votes
0answers
26 views

TypeError: Expression has to be an lvalue

I have a parent contract: contract Transaction { enum C_facts { Inital, Requested, Promissed, Declared, Accepted, Declined, Rejected } C_facts public c_fact = C_facts....
0
votes
0answers
14 views

Know which function was called [closed]

I'm using remix and i want to know which function was called so that I can update a state variable. Does anyone know how to do this?
0
votes
0answers
20 views

How can I pass an unsigned transaction to a smart contract?

I have an unsigned transaction that I got from the 0x API in my web3 app. I would like to pass it as an argument to a function within a smart contract, is this doable? how? I already read about a ...
0
votes
0answers
7 views

getTransactionReceipt() in JavaScriptVM Environment

Is it possible to get a transaction receipt using Remix in JavascriptVM Environment? If it is how can i do that? Thanks in advance
1
vote
0answers
20 views

Non linear State Machine Pattern

The State Machine presented at solidity documentation shows a good way to implement the pattern in linear cases. However, when the states don't transact in a non-linear manner there is no example. ...
0
votes
0answers
24 views

How to get a callback function to return to a separate contract? [closed]

Let's say I have the following structure: contract A { function getResult(){ unint256 result = B.getRandom(); } } contract B { function getRandom(){ // This function has a ...
0
votes
0answers
8 views

Remix not loading in Chrome and Firefox

For some reason i cant access the online Remix IDE. http://remix.ethereum.org it gives me a blank page with a logo. Tried to access from Firefox, Chrome and Edge aswell as disabling all extensions ...
0
votes
0answers
18 views

is there a way to create a ens ethereum address to be readable one using cryptography? [duplicate]

I would like to generate address which are readable to people using cryptography and supporting ethereum transactions without problems, I don't want to use ens ethereum because I will have to pay for ...
0
votes
2answers
19 views

How concatenate encodeWithSignature with another data type to external call?

There are a abi.encodeWithSignature("foo((bytes))", info), but in addition to calling the function in another contract I want to send more data as an address to retrieve with msg.data, for ...
0
votes
1answer
32 views

Piece of code with constructor [closed]

Can you explain me what this piece of code does please? i don't understand it at all. struct Candidate { uint id; string name; uint voteCount; } mapping(uint => ...
0
votes
0answers
9 views

Raise & return error with message if no key found in mapping

I am writing a test that should fail because it looks for a key that doesn't exist on a mapping. How can I raise the error with and error message in solidity? this is the test: it('Should NOT update ...
1
vote
0answers
31 views

Access the result of _; inside a modifier to change state machine common pattern

I'm implementing the State Machine for a specific case where the nextSate() depends on the execution of the method, as realistic State Machine. The code follows: contract Transaction { enum C_facts { ...
0
votes
0answers
6 views

Rerendering causes results to display twice (possibly caused by async event emission)

This may seem like a web developer problem at first but i think it pertains to how function calls are done in solidity. So basically i have a voting application which triggers an event every time a ...
0
votes
0answers
11 views

how to calculate the message part for pedersen hash in solidity

I am trying to implement pedersen hash using solidity. Is it possible to implement and how to split the message according to the conditions of pedersen hash.
0
votes
1answer
39 views

How to deploy kyber network proxy locally and test with truffle?

I am trying to deploy a proxy from Kyber Network for local development. So far I have pulled down the workshop repo and I have successfully deployed all the contracts successfully. I have the ...
0
votes
0answers
27 views

Convert address to uint160

https://solidity.readthedocs.io/en/develop/abi-spec.html "address: equivalent to uint160, except for the assumed interpretation and language typing. For computing the function selector, address ...
0
votes
0answers
11 views

Creating a system with multiple blockchains where they can interact with one another?

I'm currently trying to create a sort of proof of concept where I would like to create a system of blockchains for individual accounts to track their balances. The idea is to have a snapshot of their ...
0
votes
0answers
32 views

Solidity OpenZeppelin Documentation: Import other Contract not working

I just completed the whole documentation for OpenZeppelin and everything was working fine except the import command. I created a folder in the folder Contracts and placed Auth.sol in there. Paths: [...
0
votes
0answers
14 views

Performance of Dapps when millions of records to be fetched

I am thinking of Dapp with react js and ethereum. Using IPFS for data storage. Let's assume that blockchain holds millions of hash addresses from IPFS. I need to show those millions of records and ...
0
votes
1answer
20 views

What if millions of records to be fetched from blockchain?

This is just a hypothetical scenario. Let's suppose someone saved million of information in blockchain with huge gas consumption so far. As for reading data in ethereum smart-contract cost no gas. ...
0
votes
1answer
17 views

Access input of a different function but in same contract

Is there a way for a function B() to have access to the input given at function A(), knowing function A() and function B() belong to the same contract XPTO?
0
votes
0answers
17 views

The code is not returning the value of x? [duplicate]

pragma solidity >=0.5.0 <0.7.0; contract Example{ uint256 public x=3; function setArr(uint256 y) public returns(uint256){ x=y; return getArr(x); } function getArr(...
0
votes
1answer
38 views

Contract not showing the name and symbol

I deployed a contract on ropsten but it was not showing the name and the symbol. I have the feeling that there is something wrong at the deployment and I think it has to do with the parameters. As you ...
0
votes
0answers
16 views

Type struct Mycontract.User memory is not implicitly convertible to expected type struct Mycontract.User storage pointer

pragma solidity >=0.5.0 <0.7.0; contract Mycontract{ uint256 a; struct User { string name; } User[] users; function foo() public{ **User storage user=User("hey&...

1
2 3 4 5
175