Stack Exchange Network

Stack Exchange network consists of 175 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
2answers
15 views

Self Destruct Design pattern - Loss of funds issue

I was exploring on self destruct design pattern for a time bound smart contract. So my contract should not accept any further state change after a certain given time period. While working on that I ...
0
votes
1answer
17 views

Why we use 1000 to divide our fees?

function transferToAddress(address _to, uint _value, bytes memory _data) internal returns (bool success) { require (_to != msg.sender && _to != address(0)); uint fee = ...
2
votes
1answer
28 views

Solidity assembly function call parameter alignment

I am trying to call a function using assembly. The called function has address parameters. How to use address in assembly call? Called function example: function isSameAddress(address a, address b) ...
1
vote
2answers
50 views

Why Truffle over Remix Ide

Can anyone please let me know why I should work in truffle framework to test the contracts when I have access to Remix Ide.
0
votes
0answers
10 views

Add rule to setting.json for solidity VS Code extension

I´m using JuanBlanco solidity VisualStudio Code extension. Im geting a warning that I want to avoid. In my setting.json file I have the following rule: "solidity.soliumRules": { "quotes": ["...
3
votes
1answer
29 views

Verify a block exists

I want to verify that a block exists in a trust-less manner - i.e. with on chain validation. This rules out the option of using an oracle. I'm aware of this function: blockhash(uint blockNumber) ...
0
votes
1answer
21 views

Not a function but function is there in solidity contract

I have a function called function addUser(address pubkey) public { } However when calling this function in the node backend contract.methods.addUser(address).call().then(function(...
0
votes
0answers
16 views

ERC721 Transfer Event issue

Looking at the open-zeppelin ERC721 Contract's code, I see that the very last thing that its mint function is doing is call emit on the contract's pre-defined Transfer event. My question is: how do ...
-1
votes
1answer
40 views

UnhandledPromiseRejectionWarning: Error: invalid json request

my deploy.js script returns this error : "(node:6636) UnhandledPromiseRejectionWarning: Error: invalid json request at D:\kickstart\node_modules\truffle-hdwallet-provider\dist\index.js:15:620862 ...
0
votes
0answers
8 views

Subtraces of delegatecall in Parity trace

I'm investigating transactions using Parity trace which provides useful data over a transaction flow. Among this data is the Subtraces field which allows me to understand how many sub-calls each ...
0
votes
1answer
18 views

how to parse values returned by one contract into another?

I've two contracts deployed one is UserRegistration and another is Exam I've getUser(uint id) method to fetch data of particular user using users mapping, function getUser(uint _id) public constant ...
0
votes
1answer
77 views

I need help to understand why a function call reverted without any reason

I have a Registry contract, which holds addresses of different smart contracts. The registry has getter for every contract address it holds. In other contract at some point I need to retrieve one of ...
-1
votes
2answers
36 views

How to Learn Solidity [closed]

I know basic solidity but how i learn higher level solidity to make dapps ? What advance skill required for smart contract and Dapps development ? Where I can practice my skills ? Please Help Me. ...
0
votes
0answers
19 views

Web3 & Solidity - Automatically read ABI and Create Contract

Is there a way to automatically create a new Solidity Contract - from within a web3 JS file using the .json file created in a project's build folder after each compile? I have already figured out how ...
0
votes
1answer
27 views

Solidity Contract Needs Another Contract's Address

Is there a way for a Solidity contract to programmatically find out another solidity Contract's address? Right now I'm letting Contract A know about Contract B by hard-coding the address of B into ...
0
votes
1answer
20 views

problem calling balanceOf from another contract

I try to learn solidity and i have a problem. I've created a base token and i want to call the balanceof method from this token in another contract. In Solidity Remix i get : call to BaseTokenBet....
0
votes
1answer
20 views

receiver.payable

Truffle v5.0.5 (core: 5.0.5) Solidity v0.5.0 (solc-js) Node v10.15.1 pragma solidity v0.5.0; contract ApprovalContracts { address public sender; address public receiver; address public ...
0
votes
1answer
136 views

Use solidity contracts public property and method in web3js.Error: Invalid bytes string given: 0x

I want to use contract's property and method by web3js: versions: "ganache-cli": "^6.3.0", "mocha": "^6.0.1", "solc": "^0.5.0", "web3": "^1.0.0-beta.47" Imooc.sol: pragma solidity ^0.5.0; ...
0
votes
1answer
21 views

ERC721 Contract vs. Auction Contract - Architectural Approach [duplicate]

I'm working on a new ERC721 Crypto-Collectible project, which also means creating an Auction and Marketplace functionalities into the whole thing. Should I just start with a basic ERC721 Contract - ...
1
vote
1answer
32 views

Debugging a failed transaction

I have a smart contract deployed to mainnet. A user has executed a transaction that resulted in a revert failure. How can I debug this transaction to determine what exactly happened that resulted in ...
0
votes
1answer
25 views

Default getter and setter for mapping in solidity

In my smart contract I've public mapping as mapping (uint=>User) public users where User is a Struct, so is there any way to get the values of this mapping using default getter. For Example : If ...
1
vote
1answer
34 views

why use up all the gasLimit when use assembly and revert together?

try to call erc20 token's transferFrom() using assembly(to save some gas), code like this: pragma solidity ^0.4.24; contract TestAssemblyAndRevert { function test(address from, address to, ...
0
votes
1answer
31 views

Invalid type for argument in function call. Invalid implicit conversion from mapping

I have defined struct for saving data to ethereum blockchain. I am using uint to map the data stored with a unique ID. I am using truffle framework to write smart contracts with solidity version: 0.4....
0
votes
1answer
17 views

Solidity modifier with function call error

pragma solidity >=0.4.22 <0.6.0; contract Person { //owner address address private owner; //identity string private firstName; string private lastName; string private ...
1
vote
1answer
19 views

Accessing 'constant' variables not working

I need to access some constant variables in a smart contract, but I'm not being able to. Here's my code: decimals = await contractInstance.methods.decimals().call(); 'decimals' is a constant in a ...
1
vote
2answers
44 views

Smart Contract Working on Remix but not TestNet

This question has been asked before. however, those answers did not help me. (of course, I now can't find the "answer" atm) It said that Ropsten (what I was currently using) has fewer miners - or ...
0
votes
1answer
80 views

Truffle console error “Error: Returned error: VM Exception while processing transaction: revert”

I compiled and migrated my solidity codes of erc20 token to development networks on truffle, and use it on truffle console. truffle(development)> let instance = await XToken.deployed() truffle(...
2
votes
0answers
23 views

Is there any dynamic symbolic execution tool for smart contract [duplicate]

There is a question (Security analysis tool for Ethereum smart contracts) similar to me, but it presents mostly static analysis tools. I'd like to know if there is any better dynamical analysis tool ...
0
votes
1answer
17 views

How does this 4-line labyrinth contract work?

contract Labyrinth { uint entropy; function getRandomNumber() public returns (uint) { entropy ^= uint(blockhash(entropy % block.number)); return entropy; } } I found this weird gist ...
2
votes
1answer
25 views

What is the “^=” operator?

I found this weird gist online for generating random numbers. Please remember that, despite the code's comments, generating random numbers on-chain is insecure for values more than 2.5 ETH. // this ...
0
votes
1answer
33 views

org.web3j.tx.exceptions.ContractCallException: Empty value (0x) returned from contract

Problem: org.web3j.tx.exceptions.ContractCallException: Empty value (0x) returned from contract The code is as follows.... My java: String owner = managedWalletLookup.getOwner(contractAddress).send(...
1
vote
1answer
20 views

Is it possible to show multisig wallet transactions on metamask?

I am trying to implement multisig wallet, where one contract address is set as a wallet with multiple owners. I want to show multisig transactions on MetaMask. Is it possible to do that? My contract ...
2
votes
1answer
42 views

can anyone help to explain calldataload

In the Solidity documentation, the definition of calldataload is: calldataload(p) call data starting from position p (32 bytes) But I am really confused by what is call data. Is the call data of ...
0
votes
2answers
42 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
1answer
19 views

how to change approveAndCall() function for upgraded compiler version of solidity 0.5.1 from 0.4.6?

Here is the code snipped which is used when I'am working with compiler version 0.4.6 : function approveAndCall(address _spender, uint256 _value, bytes memory _extraData) public returns (bool success) ...
0
votes
1answer
20 views

when i call balance function it shows 0 all the time ? I am deploying at remix - solidity

pragma solidity 0.4.19; contract blackeye { uint public max_amount = 1000000; uint public total_balance_bought = 0; mapping(address => uint) total_balance; address ...
0
votes
0answers
13 views

web3.js contract instantiation failing

var Web3 = require('web3') var url = 'https://ropsten.infura.io/v3/xxxxx' var mycontract = '0x7eAd553D7E528Bdf12364177453f25bfa0682FD6' var contractAbi = [ taken from remix]; var web3 = new Web3(url) ...
1
vote
3answers
24 views

Schedule an execution of a function in Solidity [duplicate]

I am new to solidity and to smart contracts, i couldn't find a great resource describing how the execution of a function in the future really work behind the scenes and how to implement it. I'd ...
0
votes
1answer
57 views

How to convert string to bytes32 properly?

In my solidity I'm using a mapping like this: mapping(bytes32 => uint) items; constructor() { items["test"] = 2; } function getItem(bytes32 key) returns(uint) { return items[key]; } ...
3
votes
2answers
65 views

Should I give names to return values, when a function returns several of them?

I am currently working with solc v0.4.25, where it is not possible to return structures, so the only way to return multiple values is in a tuple. I've been advised to give names to each one of the ...
0
votes
1answer
26 views

Event suddenly disapears when i call another function in my contract

So i am doing a factory for an ERC20 token contract, here is my factory code: pragma solidity >= 0.4.0 < 0.6.0; import "./ERC20.sol"; import "./ERC20Interface.sol"; contract Factory { ...
0
votes
0answers
27 views

could n't find ABI constructor in my input data

I have developed the solidity code and need to verify the smart contract but I could not find Constructor Arguments ABI-encoded check the screenshots, i have developed in testnet
0
votes
0answers
14 views

web3 is not getting detected while migration in truffle [duplicate]

I am trying to deploy the contract in ropsten. In that process I use web3 for a conversion. Due to this the migration fails as mentioned below. Please assist me in resolving this. I have also tried ...
0
votes
0answers
58 views

Truffle: Error: Could not find a compiler version matching 0.5.0

I wonder why I get the error when I have v0.5.0 everywhere and do the following: In my Action.sol: pragma solidity ^0.5.0; In Migrations.sol: pragma solidity >=0.5.0 <0.6.0; When running truffle ...
0
votes
1answer
25 views

ZepplinOS: Where to set owner of the contract?

ZepplinOS contracts do not use constructors in it's zos implementation, and instead uses an initialization function that it imports from zos-lib/contracts/Initializable.sol package. In order for the ...
0
votes
1answer
43 views

NOOB Error : Transaction mined but execution failed

i´m learning Solidity now, and i saw this code on web but when i try to use the method "Deposito" i receive a error. Someone knows what's that ? (PS.: I try to put the value but every time i chose ...
0
votes
0answers
53 views

How to access the return value of function of ethereum contract using web3 in javascript?

I have written a basic hello world! smart contract and deployed using testrpc and truffle. I have a function in the contract that returns a value and i am using this function and the value it returns ...
0
votes
1answer
19 views

how can we set auto transfer of my tokens to the wallet which transferred me ethers

Okay so I have deployed my contract to network, and my wallet or account via which I deployed it contains all my tokens of the newly created contract. I dont want to list my token anywhere since since ...
0
votes
1answer
49 views

stack too deep , try using fewer variables

seems like i'm passing a lot of arguments in a struct creation, this message error showed up "stack too deep , try using fewer variables" i tried to get rid of it by using bytes32 instead of string, ...
0
votes
1answer
30 views

How to split bytes32 into multiples of 8 in solidity

I want to split bytes32 into multiples of 8 (in assembly). I have the following code(After referring here): function testAssembly(bytes32 _msg) public pure returns (bytes8 i, bytes8 j, bytes8 k, ...