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 tagged [contract-development]

Questions regarding the development of smart contracts

0
votes
1answer
20 views

ICO functions & limitations

One thing I try to understand is the limitation of smart contracts. I was looking into ICOs and I always asked a question: Is it possible to implement an 'enterICO' function without requiring ...
1
vote
2answers
81 views

ethereum smart contract security check [closed]

How to prevent smart contract from the vulnerabilities? what are all the security measurements we need to consider before publishing our smart contract? Regards Mani
0
votes
2answers
144 views

abi.encodePacked with lot of zeros

According this documentation types shorter than 32 bytes are neither zero padded nor sign extended and When I use abi.encodePacked(address, uint, uint, address) I am getting a result with lot of ...
0
votes
1answer
142 views

How calldata is stored in memory?

when I execute this: bytes8 h = 0x000008dfe2f440000733c; t.call.gas(0x7e0b0)(bytes4(keccak256("enter(bytes8)")),0x8dfe2f440000733c0000000,h); the calldata is : 0: ...
2
votes
0answers
36 views

Interacting with a complex deployed contract from my other contract

For example, I want to call a create market function from augur in my contract. I'm using the recommended pattern, but there are additional contracts that this function brings in, ex ICash, IMarket ...
0
votes
1answer
71 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() { ^ (...
0
votes
1answer
208 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
61 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
15 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 ...
1
vote
1answer
41 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
46 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 ...
1
vote
1answer
27 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 ...
1
vote
3answers
49 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
81 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
25 views

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

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
46 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
24 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
75 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
34 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
72 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
88 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
2answers
268 views

How to fix “Transaction Error. Exception thrown in contract code.”

How do I determine what functions aren't implementing? I will paste the code from both the token and crowdsale contract if needed (which I suspect it will be).
2
votes
0answers
21 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 "...
1
vote
1answer
27 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
46 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
44 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
202 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
481 views

this.balance VS address(this).balance

What is the difference between this.balance VS address(this).balance in solidity contracts?
1
vote
0answers
98 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
33 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
45 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
27 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
34 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
148 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
35 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
24 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 = ...
2
votes
2answers
166 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
64 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
58 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
25 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
22 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
171 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 ...
1
vote
1answer
18 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
53 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
60 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
44 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 ...
1
vote
1answer
41 views

How to use require() with stings

I am trying to run this code on remix IDE: pragma solidity ^0.4.24; contract Aa { string public result; function feedData(string _result) public { require(_result = "e" , "...
1
vote
1answer
21 views

how to use the logical operator “or”

I am trying to implement a simple smart contract on Remix IDE (using Genache as my local blockchain) Here is the code: pragma solidity ^0.4.24; contract Aa { uint public myuint; function ...
1
vote
1answer
54 views

How to get constants value by using Contract name

for example: contract A { uint constant public START_TIME = 10; } import "./A.sol" contract B { function test() public { uint startTime = A.START_TIME; } } If I only need the ...
1
vote
2answers
119 views

HI, can i get live Ether to USD price in my smart Contract ? I want to keep a hardcap in USD. is it possible to do so?

I want to make a function for my ICO to calculate ethers collected so far and convert them into USDollars. I wanted to hard cap my ICO in USDollars. Is it possible to do so ? I am using Solidity to ...