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

I have a question on ZepKit

The ERC20 is implemented referring to the following article. https://blog.zeppelinos.org/getting-started-with-zepkit/ I confirmed Wallet.sol at the console of truffle. Why are the arguments of ...
0
votes
1answer
11 views

3 level ether transfer

contract foster{ vulnerable v = new vulnerable(); attacker a = new attacker(address(v)); constructor() public payable{ // a.deposit(address(v)); // transferring 3 ethers to ...
0
votes
0answers
21 views

issue while deployment

Here is my smart contract on auctions: The file name is AuctionBox.sol pragma solidity 0.5.0; import "/Users/ri/auction12/contracts/Math.sol"; contract AuctionBox{ Auction[] public ...
0
votes
0answers
15 views

Unable to run the code

I need help. I was trying to create a smart contract and I checked this website (https://medium.com/openberry/ethereum-solidity-vue-js-tutorial-simple-auction-dapp-within-10-minutes-76ba48156b2?fbclid=...
0
votes
0answers
16 views

How to handle floating point number in Solidity?

I read that there is no support for floating point number in solidity, So how we can handle it. If I want to store 12.23 or something like that.
0
votes
1answer
12 views

Smart contract breaches

I am new to solidity and smart contracts. I wanted to know that can a smart contract be broken? what if I have my own smart contract made for demo and I want to break it in terms of security? How do I ...
0
votes
0answers
6 views

Execute `transferFrom` after executing `approve` on erc20

I can not withdraw from adress specified by approve. truffle(development)> erc20.approve("0x9e26730bf972d6ae8840b8f6003a61f57e25ff92", 1).then(b=>res=b) { tx: '...
0
votes
0answers
17 views

how much structure variable does solidity support?

Error: "UnimplementedFeatureError: Variable inaccessible, too deep inside stack" code: contract create{ struct s{ string s1; string s2; string s3; string s4; ...
1
vote
1answer
10 views

Web3-eth-debug “Debug is not a constructor”

I use nodejs to execute a javascript that interacts with my local instance of Ganache. I would like to use the web3-eth-debug module to get information about my transactions. However after installing ...
1
vote
0answers
15 views

How to obtain the msg.sender in truffle console?

Here is my code snippet to return the msg.sender: function showSender() public view returns (address) { return (msg.sender); } But when I try to call this function using this: Coin....
0
votes
1answer
15 views

Sending the bool to ```function() payable``` in another contract

I am trying to create a pair of contracts, let's say C1 and C2. I want to add an if...else in payable function function() public payable{} of C2, which works on the bool value returned by contract C1, ...
0
votes
0answers
20 views

Can value of a public variable in Solidity be called and returned by web3?

How to get value of a public variable in Solidity be called and returned by web3?
0
votes
1answer
12 views

Cannot call function even though it is present in the jsonInteface

I have a simple contract with a simple test-function: pragma solidity ^0.5.0; contract TestContract{ uint public a; uint public b; constructor(uint _a, uint _b) public { a = _a; b = _b; } ...
0
votes
0answers
18 views

address.transfer executes but doesn't make the transfer

I'm using Metamask and web3.js to connect with a donation smart contract. Following is my JavaScript function: function withdraw(){ const contractInstance = connectToContract(); var ...
0
votes
0answers
9 views

How to integrate Dapper Wallet smart contracts with web app?

Dapper Labs who are the creators of Cryptokitties recently released their own wallet which is run by smartcontracts. They have open sourced the code: https://github.com/dapperlabs/dapper-contracts I ...
0
votes
0answers
22 views

The send transactions “from” field must be defined on etherum

I am trying to create an E-Voting/Auction system using Smart Contracts. As per the Youtube Tutorial video https://www.youtube.com/watch?v=3681ZYbDSSk&t=217s on 1:25:23. I'm not able to get the ...
0
votes
0answers
13 views

Anything like a static delegatecall from a view function?

let's say there are two contracts A and B, where A calls methods in B. I understand that A can modify and read storage in B with B.call() and B.staticcall(), ie. A can execute B's methods in the ...
1
vote
1answer
18 views

How does a Truffle migration know the address of a contract before it is created?

How does the truffle migration of this contract know what the address is of the registry contract, in the constructor: https://github.com/marbleprotocol/humanity/blob/master/contracts/Humanity.sol ...
1
vote
1answer
17 views

Getting the transaction hash on function call

I am new to Solidity, Web3, and Ethereum. I am trying to build a web application through which users can upload a file to IPFS, then store the IPFS hash in the blockchain. I am using the React truffle ...
0
votes
0answers
18 views

How to sign a txn using web3 (1.0) and nodejs?

Firstly I know this has been asked before, but I have became confused with so many different formats and the move to 1.0. Many online resources do not make it clear about the version and I have become ...
-1
votes
0answers
19 views

Compiling Solidity contract I am getting Error

While executing this code (compiledCode = solc.compile(code)) in Command Prompt, I am getting '{"errors":[{"component":"general","formattedMessage":"* Line 1, Column 1\n Syntax error: value, ...
0
votes
1answer
12 views

How we can integrate truffle with Jenkins?

is it possible to add truffle on Jenkins pipeline?
0
votes
2answers
19 views

etherscan verification problem

For some purpose. I use web3.js 0.20 to deploy contracts.(eg. press button to deploy contracts automatically, not through remix IDE). When I deploy contracts, etherscan need to verify solidity. Is ...
2
votes
1answer
11 views

bn256 and Boneh-Boyen digital signature in solidity

I am looking to have a full-fledged implementation of bn256 in solidity. And Boneh-Boyen digital signature. Is there is any available built-in libraries or implementation in solidity to bn256 and ...
0
votes
0answers
25 views

Proxy function clashing - what kind of danger comes exactly with it?

I read that if I am using proxy, there is a chance of function clashing. Let's say in my contract there is a function with a signature: proxyOwner() ...
0
votes
1answer
18 views

How to have to two mappings to a struct?

I have a exchange type of use case in which the customer needs access to a centralised wallet based on different access methods (eg email, apikeys, actual wallet address). I tried mapping twice to the ...
0
votes
1answer
10 views

error message ParserError: Expected ',' but got 'memory'

I have this error but I do not know what is wrong? browser/arry.sol:6:58: ParserError: Expected ',' but got 'memory' function addScore(unit24 s) public returens(unit24 []memory){ ...
0
votes
1answer
15 views

Can function calls in other contracts change states?

In Solidity, is it possible to change states via function calls in other contracts? For example, let's consider the code below, where we have three assumptions: The function test2 is defined in the ...
1
vote
1answer
19 views

ERC721Token super._mint calls addTokenTo from the top level implementation

Based on Shawn's answer, super._mint calls addTokenTo from the top level implementation (ERC721Token). How does this work? super._mint calls _mint from ERC721BasicToken reads line addTokenTo ...
1
vote
1answer
17 views

ERC721 how does tokenOfOwnerByIndex() list tokens owned by a user?

Per eip-721, there's an optional "enumeration extension". So what I did was I called balanceOf to get the number of tokens owned by the account and called tokenOfOwnerByIndex in a loop to get each ...
3
votes
0answers
16 views

String Input of three numbers (comma seperated) doesn't work in Remix

So when I try to put in three numbers as a String in a usual setter-method, it doesn't work. Does anybody know why? function test(string memory x) public view returns(string memory){ return x; }...
0
votes
1answer
15 views

Error: Data location must be “memory” for return parameter in function, but none was given

I am unable to solve the error mentioned below. Error: Data location must be "memory" for return parameter in function, but none was given. function fromHex(string memory s) public pure returns(...
0
votes
2answers
20 views

How to handle JSON in a smart contract?

I want to store JSON input in my Smart Contract. Like { "name":"John" } First I thought i could just handle it like a String, but it is not working because of the double quotes. Remix says, that ...
1
vote
1answer
17 views

Where can I find public and known ERC20-Contracts from existing ICOs

In order to list real live example code for ERC20-Token and Crowdsales at a talk about Smart Contracts I'm looking for such projects? Who can recommend me the real GOOD examples out there (and not ...
0
votes
0answers
19 views

Change params from another contract

Is it possible to change params of one contract from another? I mean: contract One { address public addr; } contract Two { function test(address oneAdd) public { One one = One(oneAdd); ...
0
votes
2answers
28 views

Compare bytes32 and string using solidity

I need to compare a bytes32 value with a string. In the below example I need to check if QRVal==QRScanVal. Eg: bytes32 QRVal="0xc59aa6848d32d073bdcaa041b2735d3e4546d0836498e30de7c4c64c50933a33"; ...
0
votes
1answer
11 views

Parse Error, Expected Pragma on remix

I am new to remix and can't figure out what is wrong with this basic function. pragma solidity ^0.5.1; contract Pie { uint256 public p; } function pie () public returns (uint256) { ...
0
votes
1answer
16 views

truffle testing enum

I am trying to test an enum value from a test. This is simplified version of the contract: pragma solidity >=0.5.0 <0.7.0; contract Foo { enum State { StateA, StateB } State ...
0
votes
3answers
30 views

Solidity Compatibility Configuration

I am a cyber security analyst who is new to ethereum and working on a project to study crypto security. It's a series of 22 vulnerable smart contracts that you're supposed to exploit. For anyone who ...
0
votes
1answer
35 views

Setting array.length to 0 triggers an error on solidity 0.5.0

Why setting array.length to 0 triggers an error ? I have a function that deletes an element from a dynamic array of structs within a mapping as follows: mapping(address => MyStruct[]) public ...
0
votes
1answer
28 views

How to read uint256[] array from a method in a smart contract?

I'm using this function in my smart contract. It returns an uint256[] array containing the tokens that the user owns. /** * @dev Returns all of the tokens that the user owns * @return An array ...
0
votes
0answers
20 views

Create an ERC20 Stablecoin

How to create a stable coin with an ERC20 token contract ? Does it require contract to be modified ? Are there some good practices or standards ?
4
votes
3answers
210 views

Handling decimals in somewhat complex math

I'm a bit lost on what to do with the following calculation. The problem is that decimals are being round up/down, which obviously doesn't give me the result I desire. int totalValue = 275000; int ...
1
vote
1answer
18 views

No web3 instance injected following the dApp University Tutorials

I've been following Dapp University's videos on how to make IPFS uploads with Euthereum Smart contracts, and after I manage to 'npm run start' in the command line it opens up the HTML, but it always ...
0
votes
0answers
11 views

stack too deep user function [duplicate]

I am building a dapp, the user structure is composed of multiple attribute so I divided it to 3 structures, but I still have the problem of the deep stack in the registration function struct ...
0
votes
1answer
30 views

Web3 - Cannot read property 'clearSubscriptions' of undefined

While creating a web3 instance, and attempting to call setProvider with a valid provider (Ganache), I get a TypeError. TypeError: Cannot read property 'clearSubscriptions' of undefined Steps to ...
0
votes
2answers
20 views

how does this honeypot works?? 'OpenAddressLottery'

/** * Source Code first verified at https://etherscan.io on Saturday, February 10, 2018 (UTC) */ pragma solidity ^0.4.19; /* * This is a distributed lottery that chooses random addresses as lucky ...
1
vote
1answer
16 views

Auction contract problem regarding highest bid display

I have an Auction contract which has a function like this: function bid() payable{ //calculate and store highest bid value } But because each transaction takes time to mine, so when a user bids ...
0
votes
1answer
20 views

How to pass a document as function argument(upload document)

I am working on a project in solidity where I want to generate a SHA256 hash value for the document. So which means when I choose a file using a function the function should return the hash value. ...
0
votes
1answer
10 views

How much gas does looking up block.timestamp consume?

Trying to get some insight as to whether or not it's more optimal to call block.timestamp repeatedly for comparisons or to set a (memory) variable to hold the value and use it instead. I've looked at ...