Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

0
votes
1answer
23 views

How to cast address to address payable in solidity 0.5.0

Got address from 3rd-party library: address wallet = rlp[5].toAddress(); And wanna transfer some funds to it: wallet.transfer(amount); Got error: TypeError: Member "transfer" not found or not ...
0
votes
1answer
34 views

Upgrading to solidity version 0.5.0 getting deployment failed error with same smartcontract perfectly deployed on 0.4.24

The same smart contract is running smoothly in solidity version 0.4.24 but now when I update the solidity version and solving a lot of bugs inside my smart contract I intended to deploy that in ...
0
votes
0answers
15 views

Why the same contract has more bytecode size in solidity 0.5 in compare to 0.4.24?

My earlier contract was compatible with solc@0.4.24. Now I am upgrading my contract to make it compatible with solidity 0.5 but it leads to an increase in bytecode size. AFAICT There is no change in ...
0
votes
1answer
14 views

Error in external function parameter defination for an interface

Dear community members, I have come across an error while defining an interface (just using the standard one interface ERC721TokenReceiver) this interface is mentioned in this link https://github....
2
votes
3answers
48 views

accepting ether in a smart contract

I want to create a simple smart contract for registration of users to a competition where when users can pay to contract and 2 ethers will deduct from his account. But when I'm trying to do so on my ...
1
vote
1answer
22 views

ERC721 Default Implementation

I’m working on a card game. Right now it is really simple. There are orcs and cards. Both should be implemented as ERC 721. What would be the most natural way to make the orc an ERC-721 token? ...
0
votes
0answers
22 views

Matching inside my contract fails with multiple participants

my contract (can be found on my gist: https://gist.github.com/fabs993/e13fa6ecd9526d30c8a6d85c10180075) fails at more than 5+ participants. So in my use-case I have two kind of participants Producer ...
0
votes
1answer
12 views

Stress test DApps on rinkeby test network

Is there any way of stress testing a dapp? I developed dapp, now I want to see how much stress it can handle? I can't test it on Main Ethereum Network. At least I can do it on Rinkeby test Network. ...
0
votes
0answers
21 views

How to get the return value of call methods in web3 v1? [closed]

As explained here, when we use web3 v1, we need to use a different way of calling functions (either to read the staet by call() or execute a function by sending transaction). It is not clear how we ...
0
votes
2answers
23 views

Call of contracts function reverted

Sorry for posting a block of code, but I just can't get this to work. I am using ganache for testing my contracts with mocha and NodeJS. Every time I call doTransfer, it fails. The call is reverted....
0
votes
1answer
14 views

Associate event struct to user addresses

I have two contracts. One called User and other called Event pragma solidity ^0.4.24; contract User { mapping(uint=>address) addresses; uint addressRegistryCount; } pragma solidity ^...
2
votes
1answer
26 views

How to burn the token without burn method in contract

while time of contract development, management decided to don't burn any token and we will use our token as utility token for apps but now they have decided to burn unsold tokens after ICO. our ...
1
vote
1answer
31 views

Return a mapping in a getAll function

pragma solidity ^0.4.24; contract User { mapping(uint=>address) addresses; uint addressRegistryCount; function set(address userAddress) public { addresses[...
1
vote
1answer
18 views

How to ERC721 token using external contract to msg.sender?

I have Caller and ERC721 contract just like this : contract SampleToken is ERC721MetadataMintable { string private name; string private symbol; constructor (address _creator, string _name,...
0
votes
0answers
12 views

Using Private Blockchains/DLT (E.g., Quorum) for Cybersecurity purposes to forestall data exfiltration/data leakage through consensus mechanism [closed]

I am keen to use Private Blockchains/DLT such as Quorum for cybersecurity intent namely to deter and forestall data exfiltration through consensus mechanisms, i.e., securing read operations on smart ...
0
votes
2answers
27 views

Can smart contract send tokens/eth if it doesn't have a send function?

Let's assume you just created 1,000 tokens at address 0x012345. You, the owner of 0x012345 sent by mistake all tokens and 1ETH to a smart contract with address 0x987654. This smart contract doesn't ...
0
votes
0answers
13 views

Array Compare function returns opcode error [closed]

VMerror:invalid opcode Solidity code pragma solidity ^0.4.25; contract addition{ uint consensus=0; uint[] x; uint[] y; uint sum =0; uint sum1; uint sum2; uint length1; ...
2
votes
1answer
23 views

Burn the rest of the token after airdrop is complete

I have started to develop blockchain and learn solidity. I tried making a smart contract with the 200M supply, the creator only held 50M of the total supply and the rest was in the smart contract for ...
2
votes
1answer
15 views

Trying to understand why my test.js fails

I have a function that is not passing my tests in JS but the function works as expected in Remix. Can you help me contract.sol function test1 () public view returns(bool){ return(true); } ...
0
votes
0answers
21 views

ERC-20 decimals issue

I'm using a simple crowdsale contract: pragma solidity >=0.4.22 <0.6.0; contract owned { address public owner; constructor() public { owner = msg.sender; } ...
1
vote
1answer
19 views

Wich version of solidity do I have to use in Quorum

If I want to use Quorum, in which Solidity version do I have to write my contracts?
3
votes
2answers
31 views

Which version of solidity works web3js [closed]

In what version of solidity do I have to write my smart contracts if I want to interact with Web3.js
0
votes
1answer
15 views

approve() and sendFrom()

Im trying to run the code below in a smart contract to use as an escrow. calling approve first and calling send from later does nothing to get the tokens into the smart contract, what am I missing ...
0
votes
1answer
22 views

Fallback function calls get reverted

I created a contract which mints tokens when the msg.value is higher or equal to the token(ticket) price. Unfortunately when I send a transaction to the contract fallback it gets reverted. It's my ...
0
votes
1answer
20 views

How to instantiate an array of struct inside a struct

Collection[] public collections; struct Book { string name; address writer; bytes32 proof; } struct Collection { Book[] books; address collectionCreator; } // Question: how to ...
0
votes
1answer
33 views

Could somebody explain me what is the difference of msg.sender, spender, from, to, owner in ERC20?

I read ERC20 solidity code below. https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/contracts/token/ERC20/ERC20.sol Then, I couldn't understand what the terms of msg.sender, spender, ...
0
votes
2answers
25 views

Saving the actual data vs. hash of the data - which one is better?

I am new to etheruem, I would like to create a smart contract for keeping document data. From 2 designs below, can I know the pro and con of each one, please? put the array of raw JSON data to the ...
1
vote
1answer
19 views

Truffle - a proper way to execute a chunk of code

Let's say I have a complex operation to execute, for example deploying 6 contracts and calling functions to each one, passing addreses to few of them and executing some extra more functions. I can, of ...
0
votes
1answer
32 views

React: Please pass numbers as strings or BigNumber objects to avoid precision errors

Here is my onSubmit function: onSubmitModifyAllocation = async event => { event.preventDefault(); const accounts = await web3.eth.getAccounts(); await fund.methods.modifyAllocation(this....
1
vote
1answer
28 views

how can the smart contract auto update contract status for every 1st of each month? [duplicate]

I am new to etherum blockchain. I am working on designing the contract for payment money. The customer must pay money for rent space for every 1 month, or the contract will be invalid. How can my ...
0
votes
0answers
17 views

CORS Error for using infura

I need to call the balance function from my smart contract using my application and i don't want to use metamask and other web3 providers like infua as I am not going to send any transactions and don'...
0
votes
1answer
21 views

How to Serialize/Deserialize array of bytes?

I'm writing a smart contract and inevitably need to have arrays of bytes as input and output of functions. In remix arrays work just fine but with web3j and web3js there are several issues with arrays ...
0
votes
0answers
16 views

Track ERC20 Provenance

I was wondering if there is any way for a smart contract to determine where a specific ERC20 transfer came from. That's to say: Alice and Bob both send a transfer to a smart contract same amount &...
0
votes
1answer
17 views

How/when to use the system-level variables in building contracts

I am a newbie to this field and currently learning to write some smart contract programs. I am writing to inquire the best practice to use those system-level variables, such as BLOCKHASH, TIMESTAMP, ...
0
votes
1answer
18 views

Why does the Warning about Solidity come up?

# Why does the Warning come up? struct Owner { address owner; string ownerName; string petName; uint ownerprice; string petInfo; string petselltext; ...
0
votes
1answer
21 views

find the bytecode of a contract during compilation

Is there a solution to recover the complete bytecode (init + runtime) of a contract imported in solidity. For example "bytes code = getBytecode (Escrow.sol)" and this would be replaced by bytecode ...
1
vote
1answer
23 views

How to check if bytes variable is empty?

I have a mapping in my smart contract with bytes32 keys and bytes values. How can I check if bytes value exists for specific key? Mapping is something like this: mapping(bytes32 => bytes) public ...
0
votes
1answer
12 views

How do I get product/parcelID from particular Assigned address using struct and mapping?

struct Sellers{ address sellerAddress; uint parcelId; uint parcelPrice; } In this struct I've entered multiple parcel Ids to sellerAddress and I've retreived them using _sellerAddress. ...
1
vote
1answer
13 views

Error when trying to set a value to 0

I have a mapping that maps addresses to uints: mapping (address => uint256) mapAddress; A function then assigns a counter to the address: mapAddress[msg.sender] ++; This gives me 1. The ...
2
votes
0answers
28 views

How does the Solidity compiler translate the `using .. for` statement?

I'm trying to figure out how using [Library] for [type] is compiled by the solc compiler. I noticed that address placeholders are not in the bytecode as with other library references. So what ...
1
vote
1answer
54 views

Member “transfer” not found, solidity 0.5 [duplicate]

Get the following error message, which I suspect has something to do with the solidity version 0.5, that I'm using? Error message $ truffle test Using network 'development'. /contracts/...
-1
votes
0answers
21 views

I want to accept ether when user register

pragma solidity ^0.4.19; contract User { mapping(address => uint) private addressToIndex; mapping(bytes16 => uint) private usernameToIndex; mapping (address => uint) Balance; ...
1
vote
2answers
28 views

Solidity code Error

# Solidity Transaction code Error Solidity Code pragma solidity >=0.4.4 <0.6.0; contract PetSharing { //마스터(러브펫) 지갑 struct LovePet { address lovepet; uint ...
0
votes
1answer
34 views

Solidity Vs JavaScript?

I'm currently in the process of writing a game however a question has popped up in my head. A while back I started writing my game in Solidity (i.e the characters, names, stats etc.) and I had ...
0
votes
1answer
34 views

How to apply EthFilter to specific address?

In web3.js, we can apply event filter something like below: this.event = this.Contract.events.MyEvent({ filter: { address: "0xAccountAddress" }, }) In Web3J, it is translated to EthFilter ...
0
votes
0answers
40 views

How to use mapping with array, struct to store seller's and buyer's data in array? [closed]

contract Seller { address payable owner; address [] sellerArray; struct Sellers { address sellerAddress; uint parcelId; uint parcelPrice; } contract Buyer is ...
0
votes
0answers
21 views

How can I pass struct from one contract to another?

I have two contracts and I'm trying to pass the struct data from one to another, I can do this by creating a mapping and having a uint input associated with that struct but I'd like to get the struct ...
0
votes
1answer
40 views

Transaction fails during smart contract deployment from Remix IDE, while i confirm the transaction from MetaMask

I am able to connect to private ethereum network and able to do the transactions from Metamask, but while deployment of smart contract from remix IDE, it launches MetaMask and i get below error while ...
1
vote
3answers
43 views

How to store private data on blockchain to be readable from a contract?

I'm writting DApp on Ethereum (Solidity) and I need to find a solution how to store a private data on blockchain, when I also need to proceed them somehow. If it is only about storing, I can use some ...
1
vote
1answer
23 views

Unit test compilation failed due member not found or not visible

I have written an unit test but when I launch it I get following error: Test.sol:25:22: TypeError: Member "val1" not found or not visible after argument-dependent lookup in function () view external ...