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
1
vote
4answers
251 views

mapping one id to multiple addresses

Suppose I have a product with a specific id for sale(so I am the owner) and someone wants to buy the product from me. When he pays the price he will become the new owner of that product. How can I ...
1
vote
0answers
28 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 ...
0
votes
1answer
43 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=...
19
votes
3answers
14k views

Convert address to string

In Solidity, how can I convert the sender address to a string? The comments in How to convert an address to bytes in Solidity? did not provide a working solution
1
vote
1answer
20 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
2answers
280 views

After compiling contract, there is no build directory inside project directory?

After writing 'truffle compile' in terminal , it just give the message i.e. compiling your contracts...and exit, no build directory is formed in Project directory. What is the issue?
0
votes
1answer
11 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
9 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
68 views

Compilation failed during instrumentation of solidity-coverage

Getting compilation failed error, while running solidity-coverage. Truffle compile is working fine. Here is my truffle config: module.exports = { networks: { coverage: { host: '127.0.0.1',...
4
votes
3answers
2k views

Correctly deploying contracts with web3 1.0 and testrpc (invalid opcode error)

I followed the following tutorial: https://medium.com/@mvmurthy/full-stack-hello-world-voting-ethereum-dapp-tutorial-part-1-40d2d0d807c2 Now this tutorial is not using the recent version of web3 but ...
0
votes
1answer
31 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?
0
votes
1answer
34 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] = ...
2
votes
1answer
40 views

mapping data is not returned from SmartContract during the first time add operation

I have the below given SmartContract and the test. Please note that, when i try to execute the test, only after the second call to the grantAccess method, I am able to get the mapped value. pragma ...
5
votes
1answer
548 views

Status of ABIEncoderV2 now

Do you know the current status of ABIEncoderV2? I want to know the current status of ABIEncoderV2 Live projects using ABIEncoderV2 right now Restriction on the normal encoder Risks of using ...
0
votes
2answers
367 views

Solidity & truffle: get elements from strings array

i'm glad to follow this forum, it is very helpful. I'm using truffle to develop contracts and i just found that dynamic arrays are not yet suported, for that reason i was using string arrays with a ...
0
votes
0answers
20 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
62 views

How to use web3js to call a function with “payable” and transfer some ether to contract?

My code is like this : gameInstance.initGame.sendTransaction({from: webInstance.eth.coinbase, to: contractAddress, value: webInstance.toWei(person_num, "ether")}); Of course, it doesn't work very ...
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 ...
2
votes
1answer
546 views

How can I create an array of objects of a specific smart contract in solidity?

I am developing a university management system using ethereum. So,for that I need an entity "Student" and I have created a smart contract with some basic functionalities. Here is my code snippet for ...
0
votes
2answers
290 views

Blockchain Smart Contract EHR

I'm trying to do a miny EHR(Electronical Health Record) with Smart Contracts where I have a Pacient Contract. The problem is that in solidity everything is public, even the private variables, so I ...
0
votes
1answer
64 views

Using delegatecall for multiple parameters fuction in solidity

Does someone have a exemple of solidity delegatecall for multiple parameters function?
3
votes
1answer
65 views

What order is code copied for inheritance?

The Solidity documentation says it supports inheritance by copying code, but is unclear about where the code is copied to. I am building a genesis block for a Quorum-based chain, starting from the ...
1
vote
3answers
69 views

Cost-effective way to calculate final user balance based on variable events

Apologies for the title. I'm not sure what would be a more descriptive way to name this question. Assume there is a contract which has 3 potential parties. Buyers, sellers and shareholders. Buyers/...
3
votes
1answer
73 views

How to use enums for conditions on constructor?

I am learning to code with solidity. need help to solve this I have a membership system where users can have basic, gold, diamond membership types. Users can use coupons every 5 minutes and for basic ...
0
votes
0answers
47 views

trying to write a contract for Hotel menu in solidity, and try to map order and table number

I am new to programming, can any one help me to understand how to map the order number and the table number in a hotel contact, i tryed up to map both order and table but not able to get the proper ...
0
votes
1answer
32 views

Compatibility between ERC-1400 and ERC-1643

How does a contract supporting both ERC-1400 and ERC-1643 should be written as their functions setDocument don't have the same arguments and their getDocument don't return the same types?
2
votes
1answer
26 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
1answer
56 views

Passing ether through smart contract logic to address

I'm wanting to pass Ether through some smart contract logic then to some address set in the contract. Is this the possible, or the best way? Or should the ether be passed to contract and the receiver ...
3
votes
1answer
278 views

Geth Sync Problems | Rinkeby, Ropsten | Deploy contracts

Get Geth to sync --> Rinkeby test network. For the love of god I just want to deploy a contract. I have deployed it to Ganache-cli, GUI, remixIDE, deployed with truffle/Infuria.io...I keep failing to ...
1
vote
1answer
1k views

Solidity Bytes Comparison

I was going through the Create Your Own CryptoCurrency documentation and got stuck at the proofOfWork section. In this, they try to do a check i.e. require(n >= bytes(difficulty)) //Check if its ...
0
votes
0answers
11 views

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

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
3answers
43 views

Address as name of an array in solidity?

silly question. But can i make an array with its name as address of user? For example string[] public 0x7v77wfr349C9864De0119E94c3f8d something like that?
1
vote
0answers
15 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.?
0
votes
1answer
41 views

Deleting an array in storage (>= 0.6.0)

I need to add elements to a resizable myArray and then delete the myArray. I don't know what the length of myArray will be before the loop, and it's not possible to resize a memory array; that leaves ...
0
votes
2answers
464 views

Remix warning - Is constant but potentially should not be.

I am getting the warning on the code shown below. Could you please assist me know to resolve this warning ? warning message - "Is constant but potentially should not be"
0
votes
1answer
108 views

Have a connection problem with smart Contract using web3.js

Anyone that can help me in how to interact with our smartcontract using web3.js. I tried below code but this not work: This the code that I am using: if (typeof web3 !== 'undefined') { web3 = ...
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
29 views

Is there any security risk in keccak256 stored data in solidity smart contract?

I want to store some hashed data in my contract. Which is better, hashing on the backend(contract) or the frontend. Also, is there any security consideration to look at when doing this? Thank you.
0
votes
2answers
693 views

Error: VM Exception while processing transaction: revert: When trying to migrate a truffles initialised contract?

I'm trying to migrate/deploy a multi-signature contract through truffles, I am receiving "Error: VM Exception while processing transaction: revert" when the contract starts to migrate/deploy. ...
1
vote
0answers
9 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
2answers
31 views

How can I talk to other contracts and store their function call returns as variables?

For example, I want to grab the current borrow rate for a token on compound.finance. In this contract InterestRateModel.sol, is there a way to call getBorrowRate from my own contract and get the ...
0
votes
1answer
61 views

How can I read the entire Solidity warning in the Remix browser?

When I get a Solidity warning in the Remix browser, I can usually just hover over the warning symbol to the left of the editor and read the error message. But, this time the end of the error message ...
0
votes
1answer
103 views

getPastEvents on localhost is not a function error

Now, I'm working on an Ethereum Blockchain project to transfer the ownership of stored devices by using local web3 provider at the truffle environment. Truffle v5.0.27 (core: 5.0.27) Solidity v0.5....
0
votes
1answer
30 views

Updating inflationary token values per block?

Let's say within a specific smart contract, that deals with updating tokens values (due to inflation) on an exchange, the main way of consistently updating is utilizing a preset multiplier called in ...
0
votes
1answer
162 views

what type of encoding is used by the abi specification in solidity

the abi specification of solidity which provides functions like abi.encodePacked() using a certain type of encoding (eg: for functions, a 4 byte function signature hash followed by encoding of ...
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
2answers
581 views

Events with string argument not working (not indexed)

I am trying to listen to an event on rinkeby test which I run locally. Every thing works fine when my argument is int such as event EventTester(int values); When I change the event argument to string ...
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
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 ...

1
2 3 4 5
175