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 regarding the development of smart contracts

-3
votes
0answers
19 views

Is this contract both a token and crowdsale contract? I don't have a link so I posted the entire code below. Many thanks for any assistance given

pragma solidity ^0.4.24; interface tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) external; } contract TokenERC20 { uint256 public ...
-3
votes
0answers
32 views

Beloved newbie, why don’t you try yourself first? Just a bit, please! [on hold]

Beloved Newbie, Why do you ask us information you can find easily? Why do not try to understand by yourself? How can you come here saying us why your code do not work where a missing semicolon is the ...
0
votes
1answer
22 views

throw is deprecated in favor of revert [on hold]

pragma solidity ^0.4.24; contract Token { /// @return total amount of tokens function totalSupply() constant returns (uint256 supply) {} /// @param _owner The address from which the balance will be ...
0
votes
1answer
26 views

Constructors as functions [duplicate]

How do I fix this issue in the code below? Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead. function NMRToken() { ^ (...
-1
votes
0answers
20 views

How do I fix error: Expected pragma, import directive or contract/interface/library definition. function NMRToken () { ^------^, in the below code?

pragma solidity ^0.4.4; contract Token { /// @return total amount of tokens function totalSupply() constant returns (uint256 supply) {} /// @param _owner The address from which the balance will be ...
0
votes
1answer
16 views

Transaction has been reverted by the EVM

thanks all of guys help me. thanks very much. I created contract in rinkeby test network. the contract address is: https://rinkeby.etherscan.io/address/0x5dedcba9851e5c7ff464d5ee6ef75301a8c43d8b I ...
0
votes
1answer
20 views

Undeclared identifier 'balances'

How do I fix the undeclared identifier balances[msg.sender] = 1000000000000000000000000000; in the below code pragma solidity ^0.4.4; contract Token { /// @return total amount of tokens ...
0
votes
1answer
8 views

how do I make users sign different strings with their private key separatelly

Here is the the scenario. Users come to my website and register(by using email and password). Then they login. After that, They add a new item(which has name and quantity fields). After Clicking ...
0
votes
0answers
21 views

ethereum solidity contract interface does not work

I'm deploying 2 contracts on my private blockchain. The first one: pragma solidity ^0.4.22; contract PublicOracle { event QueryEvent(bytes32 id, uint _type, string _query); function query(...
1
vote
0answers
12 views

How can we calculate swarm storage cost?

I am trying to integrate ethereum to another fin-tech app, the basic idea is to store the transaction details on swarm and then pass the hash on ethereum network. I haven't used swarm earlier and I am ...
2
votes
2answers
23 views

how do you sign transactions programatically?

imagine there's a dapp you're building and on your website users type the receiver address, the value and what you do is send from that user's address to the receiver's address the value ether. My ...
0
votes
1answer
13 views

How to add an instance of a struct to an array of another?

Hi I am pretty new to solidity. I am busy with a project that records all kinds of information about cattle. In my code below my cattle struct has an array of CattleHealth and CattleGrowth which are ...
0
votes
3answers
35 views

Identify when a smart contract is deployed again in the network

I would like to automate the response of a Smart Contract from a script. Is there any way to identify when the contract was deployed again in the network to send a response? UPDATED: If the solution ...
0
votes
1answer
22 views

Can smart contracts make transactions on behalf of the caller?

I want to make a smart contract that wraps over other various smart contracts. In some of these contracts the user needs to send the transaction themselves. Is it possible to make a smart contract ...
0
votes
2answers
18 views

This contract does not implement all functions and thus cannot be created. for myfirstcontract contract Bank is working [on hold]

pragma solidity ^0.4.24; contract Bank { uint private value; function Bank(uint amount) { value = 10; } function deposit(uint amount) { value += amount; } ...
1
vote
0answers
14 views

how to get public key from metamask? [duplicate]

I'm creating a dapp. and I need my users on my website to provide public keys. As I am lazy to write a script which generates public/private keys automatically, I want to suggest an idea that they use ...
1
vote
2answers
17 views

block.number during development

I am developing a code that verify if a period of time has passed. I do not need precision. Just to check if aproximately 1hour has passed. I am using block.number. But, I noticed that it is not ...
0
votes
3answers
29 views

Error when trying to add a payable function in erc20

Most of the ERC20 examples on the internet have this function: // ------------------------------------------------------------------------ // Don't accept ETH // --------------------------------------...
0
votes
1answer
18 views

Two external function calls not working in combination in our smart contract

So I have the following functions buyTokens function buyTokens(address beneficiary) public payable { require(beneficiary != address(0)); require(validPurchase()); uint256 weiAmount = ...
3
votes
1answer
26 views

When is Vyper going to be production ready?

At a high level, Vyper seems like a much more adoptable language compared to Solidity. Everywhere I look, Vyper is still considered to be "experimental". Any idea of when it will be production ready? ...
0
votes
1answer
28 views

CappedCrowdsale of mintable ERC721

I am thinking of building a capped crowd sale using CappedCrowdsale and MintableERC721 of OpenZeppelin. I wonder if its better to mint the tokens once the cap is reached or to mint seperately once a ...
0
votes
0answers
15 views

Parser error on function constructor

I get this message: browser/Untitled.sol:107:5: ParserError: Expected pragma, import directive or contract/interface/library definition. function NMRToken() { ^------^ when I compile this ...
-1
votes
1answer
21 views

Undeclared identifiers [closed]

This is the full contract code pragma solidity ^0.4.24; contract MyToken { /// @return total amount of tokens function totalSupply() constant returns (uint256 supply) {} /// @param ...
2
votes
0answers
14 views

How does createProxyImpl work in ProxyFactory Contract?

function createProxyImpl(address _target, bytes _data) internal returns (address proxyContract) { assembly { let contractCode := mload(0x40) // Find empty storage location using "...
0
votes
0answers
16 views

Using Remix.Ethereum, keep receiving error “ Socket not ready. state:0 ” can anyone tell me what this means?

I have tested this throughout remix with a deployed contract and the error will still arrive, meaning i have written code, ran it, perfect, i go and add more code and receive an error so i erase the ...
1
vote
1answer
14 views

How could I check value and gas at Geth

My source below pragma solidity ^0.4.17; contract EtherBox { uint balance; constructor () public payable {} function SetBalance() public payable { balance = balance + 10; }...
0
votes
2answers
16 views

Export function variable / global variable?

modifier restriction(){msg.sender == 0x123456} function myFunction() private restriction { int a = 1; int b = 2 int c = a+b; } How do I access "c" from another function which is public view? ...
0
votes
1answer
21 views

Store N key value pairs

I have a scenario where I need to store N no. of document hashes in a smart contract with some key(id). And also fetch the particular document hash by it's key. Any help on designing the structure for ...
0
votes
2answers
42 views

How does token exchange buy and sell ERC20 tokens technically?

I am new and self studying how ERC20 token and smart contract works. After reading through some documents and blogs about creating token and ICO smart contracts. I have questions about how people ...
4
votes
1answer
35 views

this.balance VS address(this).balance

What is the difference between this.balance VS address(this).balance in solidity contracts?
0
votes
0answers
49 views

out of gas when calling a contract function which has return value from another contract

Please consider the following 3 contracts "Team", "Manager" and "Member". pragma solidity ^0.4.24; contract Member { uint8 number = 7; function get_number() view public returns (uint8) { ...
1
vote
0answers
41 views

0 ETH Airdrop function with ICO contract

I see many airdrops that have been done by sending 0 ETH to the ICO contract address my question is: how to add this function to the ICO contract with the ability to start and stop at any time? and ...
2
votes
1answer
30 views

How to verify crowdsale contract on etherscan

I'm deployed a crowdsale contract how to verify my contract on etherscan.io
1
vote
1answer
25 views

Copy state from one contract to another

I am experimenting with the zeppelin os upgradeable contracts but what I only need for my contract is to keep one specific state array when I deploy to another address. Avoiding proxy issues, upgrade ...
1
vote
1answer
20 views

Create a contract that can restrict the sale of the token in exchange

Possibility of create a contract that can restrict the sale of the token in exchange. Restrict by not selling all token only particular percentage of token. To make use of the major token in ...
1
vote
1answer
23 views

Calling transfer returns true but doesn't perform the transfer

I have the following simple transfer method in my contract to transfer my erc20 token to another account: function transfer(address to, uint tokens) public returns (bool success) { balances[msg....
3
votes
2answers
58 views

Access all the values (tuples) stored in mappings of solidity smart contract using contract address

This question addresses how a value stored in a contract variable from the outside. Is there any similar way to access a value of tuples stored in mapping(with and without knowing a key of mapping). ...
1
vote
1answer
14 views

Error when using function import in solidity and vscode

What am I doing wrong? When I use the ctrl + left mouse key combination, vscode displays the Transfer function in the ERC20.sol file with no errors. But when I call the Transfer function at the file ...
1
vote
3answers
19 views

transaction get revert by calling view method from another contract constructor

I havae two contract Record and Register. Register.sol looks like: pragma solidity ^0.4.24; contract Register { string private name; constructor(string entityname) public { name = ...
1
vote
2answers
28 views

Make Truffle deploy a contract and pass it as an argument to another contract's constructor

I have two contracts, contractA & contractB. I want Truffle to first deploy contractA, then pass it as an argument to contractB's constructor. This is what I am currently trying, but contractB ...
2
votes
1answer
28 views

Contract working on Javascript VM and not Web3 Provider, why?

Here is the code: Calling contract: pragma solidity ^0.4.24; contract Caller { address public called_address; constructor() public payable { } function set_address(address _addy)...
2
votes
1answer
31 views

How does a contract know which library to query or know the library address?

How does a contract know which library to query? For Example in the code below (The code is from solidity docs: https://solidity.readthedocs.io/en/v0.4.24/contracts.html?highlight=library#libraries ...
1
vote
0answers
16 views

Understanding Solidity Libraries using Solidity Docs code example

I was going through this code (see code below) about how to use libraries in solidity docs : https://solidity.readthedocs.io/en/v0.4.24/contracts.html?highlight=library#libraries and there are some ...
1
vote
0answers
15 views

How would ICO smart contracts function under these scenarios?

Having been inspired by an idealistic desire to attempt a way forward amidst ongoing diplomatic crises, I hired a team to help me create a mega-infrastructure ICO project at Beringia.io - but I ...
1
vote
1answer
39 views

Smart Contract storage

I was about to create my first smart contract which I came across these questions: Where exactly the contract code gets stored, I read that it kind of stores in blockchain so does that mean every ...
0
votes
0answers
25 views

How do I take a snapshot of token holders of my token [duplicate]

I have a Token with 5000 holders with a supply of 500 Million and I'll like to migrate them to a new contract of 1 Billion Total Supply. How do I take a snapshot and migrate them ?
1
vote
1answer
16 views

questions regarding how many bytes each type is

I have questions about how many bytes each type might be. Question 1) now() timestamp. i think it's uint which means uint256 which means 32 bytes? Am I right? Question 2) what does bytes32 mean? ...
0
votes
2answers
22 views

Extending Issued ERC 20 Token

I have already issued my ERC 20 token. But I want to add a time locking functionality to the token so the tokens issued during pre-sale / ICO will be time locked in user's wallets. Is this possible?
2
votes
1answer
46 views

Why use returns(bool) in a transfer function?

function transfer(address _to, uint256 _value) public returns (bool) { require(balanceOf[msg.sender] >= _value); require(balanceOf[_to] + _value >= balanceOf[_to]); ...
1
vote
1answer
29 views

Smart contract consensus - underpinned by transactions?

I can easily visualise how consensus can be reached on transactions in systems such as Bitcoin, but I struggle to understand how consensus can work in a smart contract platform - i.e how can nodes ...