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
10 views

Scaling a 'factory' design approach when listing contracts

I am building a smart contract that uses a factory contract to deploy a new sub-contract (example some campaign). This campaign has a boolean flag isActive. Every time the factory deploys a campaign, ...
0
votes
2answers
186 views

Retrieve and store data into a local database using smart contract

For my information oraclize can be use to retrieve data from several data source but what if i need to get from a local database such as oracle,sql, etc. Is there any way of doing it? PS: I am ...
1
vote
1answer
29 views

Deploy dapp on private blockchain network

i have create a private network with 2 nodes. I have connect an account with metamask from my private network and i have created a full dapp ( contract,front-end). Now i want to deploy the whole dapp ...
1
vote
1answer
6 views

Gas cost for contract transaction called form external

If I call my contract and ask it to send x amount of ether to another account y, I know i have to pay a transaction cost. Will the contract also have to pay any amount while sending the ether to the ...
3
votes
2answers
96 views

Check your gas amount error ERC721

I am trying to deploy contracts to Ganache for testing using Truffle, but no matter what I set gas price / gas limit / gas to both in truffle.js and Ganache itself, it always get check gas amount on ...
0
votes
1answer
17 views

DeclarationError: Identifier not found or not unique and Undeclared identifier

I am trying to create a crowdsale contract using zeppelin. But i am facing following errors. CrowdSale.sol:6:46: DeclarationError: Identifier not found or not unique. contract EdCoinCrowdSale is ...
0
votes
1answer
33 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 ...
2
votes
2answers
74 views

Syntax Error: Type tuple(bool,bytes memory) is not implicitly convertible to expected type bool

I am trying to compile the following program: pragma solidity ^0.5.1; contract MKotET1_1{ address payable king; uint public claimPrice = 100; function calculateCompensation() public ...
0
votes
2answers
110 views

Airdrop token code not working

I have this code to send a multi-transaction of token in a short airdrop pragma solidity ^0.4.18; contract ERC20 { function transfer(address _recipient, uint256 _value) public returns (bool ...
0
votes
1answer
74 views

How can I carry out the operation of “withdrawing eth from an ERC20 contract into a wallet” from the onchain (i.e., from another contract)?

In MainContract, I need to perform an atomic transaction which includes the following: Transfer eth from Contract1 (which is an ERC20 contract) into a given address Change a state variable in ...
2
votes
2answers
41 views

Metamask injects one account in web3, but calls contracts using another account

Building a React app, MetaMask injects web3, I get accounts[0] from getAccounts(), then pass it to my contract functions together with other parameters. I want my modifiers to lock incoming function ...
0
votes
1answer
121 views

Synchronous call of external contract function in Solidity

I have two Solidity contracts, where contract Caller depends on a second contract Callee. Contract Callee provides a public view function which checks the validity of a string (e.g. an password), ...
0
votes
1answer
113 views

How to create contract in geth private blockchain network?

I am able to publish my contract in testrpc , but when i am trying to publish same contract in geth, i am getting below error: creation of lease errored: Gas required exceeds limit: 3000000. An ...
0
votes
0answers
10 views

How to send data to transactions - ethers.js

I want to send a vote to every transaction. As transactions only happen when the required votes are met and i want to store the vote count to specific that transaction. i am using ethers.js my ...
0
votes
1answer
18 views

setting array in Solidity

consider the following solidity pseudo-code: contract Test{ bytes ar; function set_a(bytes val) external{ //(1) ar = val; //(2) for (uint i=0;i < val.length;i++) ar[i] = val[i]; } } ...
0
votes
0answers
8 views

Oraclize : Calling more than one API independently

There are 2 API 's which has to be called in different time delays recursively. For example : API_1 = 20 mins delay and API_2 = 24 hr delay. How can we call the above 2 API's independently based on ...
2
votes
2answers
43 views

Where is the length of an array located in terms of memory layout?

For example, given the following cases: uint[3] memory arr; uint[] memory arr = new uint[](3); Suppose I try to access arr from within an assembly block (using mload, for example). Where (...
1
vote
0answers
6 views

Oraclize ethereum bridge : Notifying __callback tx error to frontend

I have called API dynamically using Oraclize with the delay of 10 minutes. The code is shown below and it works well. uint256 constant DELAY = 60*10; event Log(string result); function ...
0
votes
1answer
99 views

How to identify the bytecode of a single function

I am trying to generate the bytecode for a single function. I need to avoid any setup/teardown that may occur in the contract as I am trying to get a precise measurement of the execution time in the ...
0
votes
2answers
255 views

Basic Crowdsale Contract

I am learning to develop smart contract using Solidity. Currently, I am working and test the feature of following crowdsale contract. https://github.com/OpenZeppelin/openzeppelin-solidity/blob/v1.8.0/...
1
vote
1answer
30 views

low-level call failed

I'm using the crowdsale contract (https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/contracts/crowdsale/Crowdsale.sol). I have deployed a detailedERC20 smart contract. When I send the ...
0
votes
1answer
37 views

.transfer fails

Trying to call .transfer() within a function makes it fail. I am aware that the difference between .send() and .transfer() is that .send dont throw. The function works properly when using .send(), but ...
-1
votes
1answer
27 views

Factorial contract errors in version 0.5.1

This factorial contract is worked in 0.4.24 version, there were warnings, but it is raising errors in version 0.5.1. How to solve the problem? pragma solidity 0.5.1; contract factorial{ uint ...
0
votes
2answers
23 views

Do I need to include erc20 standared function in all smart contract?

erc20 token standard functions are only important for creating new tokens, or for all, suppose a smart contract is only intended to transfer token, should it contain those standard erc20 functions or ...
2
votes
1answer
33 views

What is the current distribution of ERC Token Standards in the top 100-1000 most active token contracts?

From ERC 677 Motivation ERC20 requires a multistep process for tokens to be transferred to a contract. First approvemust be called on the token contract, enabling the contract to withdraw the ...
1
vote
1answer
37 views

Is it possible for send() in Solidity to fail if value is sent to a valid external account?

I want to use something like the following as a fallback for failed transfers: if (!recipientAddress.send(amount)) { ownerBalance += amount; } After reading about using transfer versus send, it ...
0
votes
1answer
63 views

Does this function makes my contract weak?

Ive just published a contract to etherscan, but notice something that i miss. One of my payable function (deposit()) is not set to be called only from owner. Is it going to make me troubles and should ...
0
votes
1answer
78 views

How to store the user activity in smart contract or can I use smart contract to track all user activity on my site?

New to blockchain and smart contracts. Been doing research and I am having a CRUD application in SQL Server. I want to use ethereum private blockchain to record all the user activity. Can I use for ...
6
votes
6answers
12k views

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

I have created the contract below using the online IDE Remix. the smart contract was fine until late last night when i got the following error for all functions(targeting the string data types ...
1
vote
3answers
29 views

Verify if an input is a hash

What is the best way to verify that a text I received in mu function is a valid hash? In other words, contains a specified length and is composed only by numbers and "a", "b", "c", "d", "e" or "f"?
1
vote
2answers
792 views

Ethereum Contract auditing(solidity)

I am a student of Information Security and my teacher has given me the task to know about the details of auditing that is being done on Ethereum smart contracts that are written using solidity. ...
0
votes
1answer
73 views

unable to read updated value after smart contract execution

I am new to blockchain. I am trying to implement a dapp project in my college curriculum. I am trying to implement seller-buyer smart contract on private ethereum node(using solidity, geth console, ...
0
votes
1answer
84 views

Question about how to have interacting contracts

Let's say I'm doing a crowdsale, but instead of selling a set amount of tokens I'm just giving tokens away at a pre-set price. In other words, my token has the following functoin: function give(...
0
votes
0answers
32 views

all web3 call methods returns null

I create my contract with the following code: pragma solidity ^0.5.0; contract Coin { function sayHello() public view returns(bytes32) { return "Hello"; } } truffle-config: module....
0
votes
1answer
67 views

Can someone confirm that the sender will receive the correct amount of tokens?

I've tried to get this to work. But every time I deposit 1 Finney it only gives me 0.00000000000000000001 Tokens. What am I missing? For every 1 Finney, I want the buyer to receive 1 KEFT token ...
2
votes
2answers
76 views

How can I peek into the stack using inline assembly?

I am specifically interested in calling a function whose return-type is unknown to me. More precisely: The contract which owns the function has had several versions over time My contract may call ...
0
votes
1answer
79 views

Can't use token variable's method at contract that inherit zeppelin crowdsale?

Calling the method of Crowdsale's "token" on the source that inherited Crowdsale of zeppelin v1.8.0 inevitably causes "out of gas". Error: Error: VM Exception while executing eth_call: out of gas ...
0
votes
1answer
106 views

Mining In Remix IDE

Normally in MIST, we have to mine by miner.start() to deploy the smart contract. But in Remix we don't need to mine. Can someone tell me why is that ?
0
votes
1answer
158 views

ERC20 token with expiration date

I would like to create a ERC20 token with an expiration date to represent for example a ticket or a gift card. I've created a contract which overrides the open-zeppelin ERC20 contract methods. ...
1
vote
2answers
106 views

ERC20 Interfaces overwriting ERC721 functions - Possible to adhere to standard?

Is it possible to have a contract that both generates and manages its own NFT according to the ERC721 Standard, and is able to make calls to outside ERC20 contracts? My contract currently inherits the ...
3
votes
2answers
711 views

Truffle Compile with Solidity 0.5.0

I just upgraded my code to Solidity 0.5 and am trying to use the truffle framework with it. I did update my code in Remix and it does seem to work. The problem I have is that I am unable to compile ...
0
votes
1answer
76 views

Can not see Solidity events

I can see events in a private net, but when I connect to "real" net, I can not see them. Meaning .watch(function(err, result) is never called. My theory is I am using lightning, and it probably means ...
0
votes
0answers
14 views

storing ERC20 inside of Non-fungible tokens?

Is it possible to store value in the form of ERC-20 tokens inside of non-fungible tokens such as ERC-721? If so, could someone showcase how through an example?
1
vote
4answers
153 views

Get the first transaction from an account

I'm building a Dapp where, whenever a user creates an account, a contract is immediately created from his account. However, I need a way to quickly find the contract's address in the future. The ...
1
vote
3answers
183 views

how to implement an airdrop function inside a smart contract

I have a Erc20 token X and an Smart Contract A Smart Contract A contains 1000 X Tokens. How can an User get an defined amount of X Tokens from this Smart Contract? (something like an Airdrop) So ...
0
votes
1answer
142 views

How to map multiple time and index value on same address

I wish to map the time to the address key. But currently it is working on the index key only. I just want to map time as well. Means the current time. So that I can able to get the record with time as ...
1
vote
1answer
81 views

is there any way to have a permanent refund contract for ERC20 tokens?

Im a newbie when it comes to Ethereum but from what I gather, there is a type of crowdsale where if the goal is not met, the investors can send back their tokens and get a refund. However, this is ...
0
votes
1answer
126 views

contractInstance.methods.issueTokens is not a function

I am trying to issue a transaction from my UI using metamask and web3 to a deployed contract on ropsten. Whenever I go to send the transaction with the required uint input, I get "contractInstance....
0
votes
1answer
75 views

Event filter of a contract doesn't filter light client

hello i use the env is android go ethereum light client not web3j not web3j i init geth code FilterQuery selfFQ = Geth.newFilterQuery(); selfFQ.setTopics(Geth.newTopicsEmpty())...
0
votes
3answers
96 views

Is it possible to transfer amount from 1st account to 2nd when transfer function is invoked by 3rd account?

suppose here i have three accounts and they have some balances!! i want to transfer balance of 1st account into 2nd account when transfer function is called by the 3rd account! if this is possible ...