The Stack Overflow podcast is back! Listen to an interview with our new CEO.

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
2
votes
1answer
14 views

If external function declarations are saving gas, why aren't we using it for the transfer functions?

All the source code I could find (to date) has declared transfer, transferFrom, approve, approveAndCall as public and not external. Although external can be used, what is the reason behind not using ...
0
votes
1answer
16 views

Not able to successfully send Transactions via MetaMask on Firefox Browser

Does anybody help me figuring out why I am getting failed transaction here?What does this error means? Few days back,with the same line of code,I was able to successfully send transactions. An update:...
0
votes
1answer
30 views

Error Handling on Contract Calls to Other Contracts

I'm trying to call a function from another contract and need a way to accommodate errors. Say contract A has the method getBalance: function getBalance(address x) public view ...
0
votes
0answers
23 views

Comparison of 2 child-contract-values in factory-contract

in my solidity code I create a tracking-contract and auction-contracts out of a factory-contract. The last function 'a4_Payment' of the auction-contract should be triggered out of the master-contract ...
0
votes
0answers
9 views

How to deploy smart contract with private wallet?

I am now deploying smart contract using ganache localhost:7545, i want to use infura ropsten account to deploy. Most examples uses Metamask, but i want use own ethreum wallet. How can i use to deploy? ...
0
votes
1answer
27 views

CompilerError: Stack too deep, try removing local variables [on hold]

interface AgreementInterface { function newAgreement(string _leaser, bytes32 _houseId, string _houseAddress, string _describe, bytes32 _signInfo, uint256 _rental, uint ...
0
votes
0answers
28 views

solidity - Send token without using transfer function [on hold]

function purchaseWithToken(uint256 amount) public { require(amount > 0 , "Purchase require amount > 0"); require(_balances[msg.sender] >= amount , "amount not enough"); _balances[...
0
votes
1answer
21 views

How can a smart contract payable based function returns value against any purchase

I am trying to get a return value from the payable function, the idea is a user must pay the fees and in return, he will get his special code. My JS test code is as follow it('get special code ...
0
votes
1answer
9 views

How to set constructor parameters before deploying in remix?

I don’t understand how it works. I created a contract with a constructor with parameters. But I don’t understand where to pass these parameters to the constructor. Or I need to set params after ...
0
votes
1answer
15 views

How to have ecrecover return nothing ? I means which value for malformed input?

I have a contract where the hash value is also the key to unlock the money. As the full ecrecover parameters are fetched from transaction parameters, and it was compiled in 2016, it is vulnerable to ...
0
votes
1answer
21 views

How can I interaction to a contract by address from another contract?

I have to access methods of one contract from another contract body. How can I realize that using just a address of first contract? contract KittyShelter{ address KittenRegistry; //Here, ...
0
votes
0answers
16 views

Can a factory-contract access/read/modify variables in generated child-contracts?

at the moment I am experimenting with the factory/child-logic in solidity. With my factory contract I am able to create child contracts in which an auction is executed. Now I want to return a variable ...
0
votes
1answer
16 views

TypeError: market.FileViewed is not a function while trying to watch event

I want to watch for fileViewed event and it throws TypeError: market.FileViewed is not a function in marketplace.FileViewed{ ^ My solidity contract: pragma solidity ^0.5.0; contract ...
0
votes
0answers
14 views

cloning div container number of deployed child contracts time and put their data inside div container

Sorry for the silly question. I have a div container "product-card" , I want to loop the number of my deployed smart contracts time. every time when I loop I want to clone this div container and ...
0
votes
0answers
6 views

hwo to identifie error from transaction error object?

is it possible to know what is the reason of transaction error from "error" object (nonce, insufficient fund ..) is there status or something to test using it ? Geth error message is generic, I ...
0
votes
2answers
27 views

solidity - How to detect an ERC token has just transferred money to my contract

I am developing an application that automatically converts eth, usdt ... to my token when they transfer money to my contract address. With eth, I can do it, but how to detect other erc tokens, ...
0
votes
1answer
6 views

truffle compile/migrate gives error: “ParserError: Expected pragma, import directive or contract/interface/library definition.”

The tutorial I'm following created a 2_Migrations.sol with the following: const Token = artifacts.require("Token"); module exports = function(deployer) { deployer deploy(Token); }; "Truffle ...
0
votes
1answer
20 views

Could I implement a kill switch in my solidity program?

I was wondering if there was a way to put a killswitch into my solidity code? I am using v0.4.21+commit.dfe3193c Thanks a bunch!
0
votes
0answers
33 views

Solidity bytecode not generated despite no errors

When does a compiler fail to generate bytecode for solidity? The code compiles entirely but both remix and solc js give proper abi but empty bytecode. The contract imports ERC721. Solidity contract: ...
0
votes
1answer
19 views

Why is my code calculating incorrectly, it feels right to me?

Why does this keep returning 0? And yes, it is above the claimtime. It does it for every address. I don't know what's wrong? function ViewDividendOwed(address _addr) public view returns (uint256) { ...
0
votes
2answers
82 views
+50

How to send ETH to address(0) from msg.sender address using multiple token's contracts, with Solidity 5.x?

I need the safest way for an user to send any amount of Ethereum to address(0). The amount is calculated by the contract, and there is no limit (assuming there is enough funds). All the code I could ...
1
vote
1answer
37 views

How do I burn the exact ETH gas amount within a Solidity function?

What I am trying to do is simply increase the gas costs of running a solidity function, making sure that the right amount of gwei is spent/burned. Any good, simple, and a clean way of doing this ? -...
0
votes
0answers
14 views

solidity - how return array address

contract Referral is ERC20 { using SafeMath for uint; uint8 constant MAX_REFER_DEPTH = 3; uint8 constant MAX_REFEREE_BONUS_LEVEL = 3; struct Account { address payable referrer; uint ...
0
votes
1answer
25 views

How to change push() method to simple code?

I have this code but it's static and I wanna change it dynamically. function addCandidates(){ if( own == 1 ){ candidate[0].candidate_ID[0] = 1; candidate[0].candidate_ID[1] = 2; ...
0
votes
0answers
21 views

Recursive binary search function (in solidity) not working

This is recursive binary search function in solidity. I run the SortTESTER function to populate an array with values. Then I run the SortUserData function to check values which passes the values to ...
0
votes
1answer
21 views

How to decode error response from contact

I call a function that I expect should fail by invocating 'revert'. Below is what I get as response: { "jsonrpc": "2.0", "id": 1, "result": "...
0
votes
0answers
17 views

Why is my Contract interaction cost so high?

When interacting with the UI of my application, it says the cost of doing this interaction through metamask is 400 ether. I am using Ganache for testing which only allows you to have 100 ether. I am ...
0
votes
2answers
43 views

Recursive function in solidity?

I need to call a recursive function with if statements. Is this possible in Solidity? Please provide an example.
0
votes
1answer
19 views

Checking TokenBalance of other token contract

I try to simply check a users DAI token balance on Kovan testnet (ContractAddress: 0xC4375B7De8af5a38a93548eb8453a498222C4fF2) with the following code: pragma solidity ^0.4.16; contract ERC20 { ...
0
votes
1answer
29 views

Solidity - Creating child contract

Recent code: pragma solidity ^0.5.11; pragma experimental ABIEncoderV2; contract Master { address Pi_C_Owner; address payable public NewAuctionPayable; //Hilfsvariable um ...
0
votes
0answers
19 views

how to write a program to check the nearest store in solidity [closed]

contract Evcharge { using Itmap for Itmap.AddressUintMap; event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed ...
1
vote
1answer
38 views

Value of msg.sender in call to inherited external function

I found this in the official solidity docs. The values of all members of msg, including msg.sender and msg.value can change for every external function call. This includes calls to library ...
0
votes
0answers
22 views

Cann't send token with looping function

Sorry, I'm a newbie on ERC721 token. Please help. I have deployed ERC721 contract in the localhost testnet. I use looping function for mint token and it works. But when I use looping function for ...
0
votes
0answers
7 views

How to simulate 2 accounts on the same Ropsten network using MetaMask and Remix?

I was able to deploy to the contract and everything but I wanted to see another account interacting with the contract, but on Remix only one account at a time
0
votes
1answer
13 views

Are there any virtual IoT simulators that facilitate the connection with Ethereum Blockchain?

I already built a smart contract for Ethereum Blockchain by using truffle; Now, I'm looking to connect my smart contract with the IoT environment. So are there any IoT simulators (platform, framework,...
0
votes
1answer
41 views

Solidity smart contract function in function [on hold]

I tried to write a smart contract like the following. There are two function of a contract: the first function makes confirmation of a condition, the second function makes a new contract, if all ...
0
votes
0answers
16 views

Can we connect custom Ethereum currency through java's web3j library ? If yes then how?

Im trying to create my own new currency using solidity and ethereum platform and also i want to create an Ewallet of my currency using java so that my ewallet could communicate through api .If u ...
0
votes
1answer
15 views

how to put struct “s1” values in another variable

how to put struct "s1" values in another variable. pragma solidity ^0.5.1; contract MyContract{ struct student{ int RollNo; string Name; } student public s1=student({...
1
vote
0answers
27 views

Function selector computed differently for libraries?

As documented in various places, the function selector is computed as the first four bytes of the keccak256 hash of the function header, which consists of the function name followed by the list of ...
2
votes
1answer
68 views

If a function calls another function in another contract, where is the called function executed?

When a contract calls a function in another contract, is the called function executed in the same EVM as the caller function, in another EVM on the same node or in another random node?
0
votes
2answers
19 views

Check if contract exists in list

I've got a contract which creates another contracts and stores them in a list. How can I check that contract with specific index already exists? import "./User.sol"; contract Main is Ownable { ...
0
votes
1answer
17 views

what is 'UnimplementedFeatureError: Not yet implemented - FixedPointType' error?

what is 'UnimplementedFeatureError: Not yet implemented - FixedPointType' error in solidity while compiling through truffle ? How to fix it ? Using solidity compiler version - 0.5.9
0
votes
1answer
37 views

how can i count how many buyers made request to my smart contract and get earnedEther [on hold]

I am using a factory contract for selling and buying goods. how can retrieve how many buyers bought and calculate how much ether earned by selling goods? here is my source code. I am new on smart ...
0
votes
1answer
39 views

Must consider things for every smart contract

When creating smart contract from scratch, what kind of things you should consider? For example: 1.Certain functions should be accessible only by creator/specific addresses 2.Fallback function Is ...
0
votes
2answers
23 views

How bad is it to change a function inside ERC721 interface?

I'm creating a NFT and I want the transferFrom function to be payable. In order to do so I need to edit the ERC721 interface and make that function payable also there. If I do so everything compiles ...
0
votes
1answer
21 views

Keeping a finite set of addresses (Solidity)

struct Data { ... } contract Court { mapping(address => Data) subcourts; } I want to keep track of a small finite set (which can be added or removed) of all keys of this mapping. What is the ...
0
votes
2answers
36 views

app.vote(1, {from: web3.eth.accounts[0] }) not working

I am following a tutorial from Dapp University about building Election Smart Contract. When I run this command in the console: app.vote(1, {from: web3.eth.accounts[0] }) I get the following error: ...
0
votes
0answers
16 views

Approving tokens from original contract, how would you do it?

I need to create a general approval for a transferFrom function for an exchange or general contract if you will. I've tried many ways in solidity to reference the old contract, including using tx....
0
votes
0answers
13 views

“drizzle-react-components” import Error for “LoadingContainer”

I am trying to import import { LoadingContainer } from 'drizzle-react-components' Which I succfully installed with npm install drizzle-react-components@1.3.0 It was installed inside the directory ...
1
vote
2answers
39 views

Function overriding versus Solidity Compiler Warning: Function state mutability can be restricted to pure

I have a function in a base contract that could have the state mutability modifier "pure" because it always returns true: BaseContract { function x(bytes memory) public ...