Questions tagged [contract-design]

for high-level questions about the choices made during contract construction

349 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
1
vote
0answers
40 views

What is the most preferred way to listen to events

After studying about solidity events, my understanding is that receiving an event doesn’t guarantees that the transaction is final. Transaction may yet to be included into the block. And even if it ...
1
vote
0answers
69 views

How can I create array of array contains characters with solidity

I recently approached the Smart contract two days ago. I'm still learning about it, and I have a lot of difficulties. Can you help me to create a variable like this photo? It has a arrays of numbers ...
1
vote
1answer
76 views

Access manager in Smart Contract

I'm building a service where one can publish a crypted file on the internet which can be accessed and decrypted by people allowed. I don't want to store any crypted key on a server or something. For ...
1
vote
1answer
65 views

Filter topic across multiple contracts

Is there something I could add to my contract which allows my application to filter for all the deployed contracts which also included this topic/identifier? The only other option to manage this I ...
1
vote
0answers
64 views

How do we deploy a smart contract with Oraclize to Rinkeby Network?

I have created a smart contract with Oraclize logic which I tested locally using Truffle. Now I want to test it on Rinkeby network along with my front end, what it the process to do so ? How do we ...
1
vote
0answers
88 views

How to pre-compute Gas requirement of a function to avoid metamask error

How can we pre-compute Gas needed for successful execution of a function inside a smart contract. I got to know about web3.eth.estimateGas but cannot follow it completely from the docs. My function ...
1
vote
1answer
70 views

Payable contract with multiple “options”?

I'm trying to create a contract that behaves differently based on the user's selection. I, however, have no idea how to let the user "select" the option. Currently I have a basic fallback function ...
1
vote
2answers
60 views

The correct approach to changing inherited variable content

What is the correct approach to change the content of an inherited variable? If contract A inherits contract B which has an variable b, and contract A is initialising the inherited variable b ...
1
vote
1answer
38 views

Ethereum Contract Simplify

I'm confused about 'contracts' in Ethereum. When do I need a 'contract'? For the scope of my app: I want user to be able to generate ETH address, receive and send out ETHER and I should be able to ...
1
vote
2answers
122 views

Transactions of ether between contracts

I am trying to figure out how transactions between contracts work and what you can and cannot do. I want to have a contract that makes some logical decision about who to pay when poked by another ...
1
vote
0answers
68 views

Can Factory Contract Be Used As Parent/Child Function?

I am attempting to modify the contract below; the way it is set up at the moment is so that the contract can be deployed, and then anytime a user wants to create a campaign, they can do so without ...
1
vote
2answers
237 views

function approveAndCall error

I creat token contract using remix. The function approveAndCall code is following. function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) { ...
1
vote
0answers
96 views

Why transaction hash isn't available inside solidity function call

I recently bumped into this Is it possible to get the transaction hash from within a Solidity function call? while I was looking for a way to save the transaction hash inside my contract. And ...
1
vote
0answers
319 views

Paying for gas on behalf of users?

I'm exploring ways to enable contracts/dApp owners to pay for gas on behalf of users. I know contact abstraction should enable this eventually, and the first step has been done with EIP208 which ...
1
vote
0answers
72 views

Calculating gas cost of a transaction on-chain

We can read the gas limit and the gas price of a current TX in solidity. However, reading those values already uses some of the gas. What is a reliable way to calculate the actual gas cost of a ...
1
vote
1answer
434 views

Smart Contract Deposits From Multiple Users

I want to create a smart contract which will allow multiple users to deposit / withdraw funds. My first approach was to simply have one contract address which will store the funds of all users and a ...
1
vote
0answers
97 views

Serial numbering

Let's say I want to represent bank notes. Let's say that there are 50 billions bills in circulation. Each bill has a unique serial number, starting from 1 and increasing by 1. Each note has some ...
1
vote
3answers
54 views

Is there a way to safely send ether from a contract without the recipient triggering it?

In an auction-like setup, I'd like to be able to automatically "refund" players if they get outbid. It seems like everyone recommends a manual "safe withdraw" pattern, where the player would have to ...
1
vote
0answers
82 views

Is there a secure implementation of inheritable Withdrawable/Withdrawal Pattern contract?

I'm building a contract which allows users to pay, earn and withdraw ether. I want to keep it modular, so I want to write a contract named "Withdrawable". The core contract will then inherit it and ...
1
vote
0answers
370 views

Solidity if condition based mapping with multiple struct

I'm trying to map with more than one structs. First mapping contains common details need to be mapped to every item and then second mapping should be carried out according to the item type. ...
1
vote
1answer
200 views

Private Ethereum Smart Contract API call to notify (without needing the external api response to update the state) without using Oraclize

In a Private Ethereum Smart Contract, can we do an external API call just to notify (without needing the external api response to update the state) without using Oraclize? Understand Oraclize is ...
1
vote
0answers
30 views

Recovering the message that is digitally signed not only the address

Is there a way to recover a digitally signed message in a smart contract? ecrecover(msgHash, v, r, s) returns the address that signed the msgHash. I am looking for something that can return the ...
1
vote
0answers
86 views

Assigning memory values to storage compiles?

i came across some weird problem between storage and memory variables. In my contract i have the following function. the first snippet of code does work. the second doesn't but it does compile! so i ...
1
vote
0answers
62 views

Re-entracy without fallback function?

Re-entrancy mainly occurs when one contract calls the fallback function of another contract and it again invoke the same caller function and it keeps on doing this. This is pretty much clear. But can ...
1
vote
0answers
52 views

Back of the envelope Oraclize callback cost calculations for

How does one do a back of the envelope calculation about how much the Oraclize callback will cost? Does it cost more if a query is returning a large amount versus a small amount of data? Does it cost ...
1
vote
1answer
630 views

Where do you save the application data of a Dapp?

Let's say that I want to implement a Dapp similar to Facebook. Each user has its own profile, pictures and information. Usually you would use a database to store all this data. This guarantees that ...
1
vote
0answers
33 views

Are API tokens incompatible with Ethereum apps?

I want to build an Ethereum app that gets weather data from a trusted (government run) API via oracilize. This service requires an API token to be sent with each request to prevent abuse. Each API ...
1
vote
2answers
65 views

accessing unpredictable numbers

I see that this has been a widely discussed topic in the past but I still don't understand why the future block hashes shouldn't be used for lottery-type games. As long as the incentive for a miner to ...
1
vote
3answers
324 views

Repetitive validation through Modifier or function

What is the benefits from writing repetitive validation as functions instead of modifiers? The documentation clearly recommendations to use modifiers yet 'best practice' open source parties such as ...
1
vote
0answers
294 views

Error encoding arguments at position 2

I keep getting following error: SyntaxError: Unexpected token “ in JSON at position 2 when I try to call following function, below is how I call it. ["ADDRESS","ADDRESS"],"STRING" This is ...
1
vote
1answer
98 views

retrieving tokens from contract

I am using the MyAdvancedToken code from: https://www.ethereum.org/token I transferred tokens from owner account into the contract, to fund any buy(). Now, I want those tokens back. Is there any ...
1
vote
0answers
208 views

Create contract that receives and sends bonus money to many addresses. What is the gas price?

I would like to create a contract that holds references to 20 Ethereum addresses. Each address has some associated Ethereum value. I want to send the message to this contract later and call function "...
1
vote
2answers
3k views

What is a revert opt code?

I send ETH to a smart contract of my own, and it always fail. At etherscan I search the failed transaction and it has this message: "Value transfer did not complete, most likely as a result of a ...
1
vote
0answers
596 views

12/30/17 ERC20 Sample Fixed Supply Token Contract totalSupply function

The latest Sample Fixed Supply Token Contract in the 30 December 2017 revision of the ERC20 Token Standard has some great improvements that our team was wanting to add to our contract in test. It is ...
1
vote
1answer
358 views

What is the point of having stateRoot rather executing every transaction?

EVM is a deterministic meaning that if any two(or more) nodes receive identical transactions in the same order(which is what blockchain is for), they will arrive at the same state independently. And ...
1
vote
2answers
1k views

Remix: This contract does not implement all functions and thus cannot be created error

I have 2 contracts: pragma solidity ^0.4.18; contract Coin { function transfer(address whom, uint256 amount) public; } contract ManagedWallet { event ReceivedEther(address source, uint256 ...
1
vote
0answers
41 views

Contract Oriented Language Fundamentals, “God” Contracts and managing large token storages?

Just going through some of the 0x Contract Code trying to improve my understanding of solidity and Smart Contract oriented language programming. Stumbled on the TokenRegistry.sol contract and trying ...
1
vote
0answers
25 views

Obtaining list of all addresses having sent money to a specific adress inside a Solidity contract

For a certain contract A to execute and transfer specific amounts to other sub-contracts, I need a way to determine all the contributors amounts and addresses and make certain computations before ...
1
vote
1answer
44 views

Best Practice for Arrays you will Write to Often

I want to build an App with an array data structure that I would like to keep private. So far, I've wanted to build it between IPFS and Ethereum. But what would be best practice for an array that I ...
1
vote
0answers
237 views

Can contracts trade on etherdelta?

I was told that contracts can not trade on etherdelta because they can not sign transactions, could someone clarify?
1
vote
0answers
30 views

Use-Case: building a small test-network, did I got it right?

I've to implement a simple use case and I'm not really sure if I understood everything correctly. What I'm trying to do is to build up a network with a few Raspberry-Pi's, running as full-nodes. ...
1
vote
0answers
449 views

How to reference the contract definition within the contract itself?

I'm working on the problem of smart contract upgradability and in that, I'm calling kill function of the contract with newly deployed contract's address as an argument. So that kill function can link ...
1
vote
2answers
469 views

Smart Contract - Update implementation using a Relay with delegateCall

I know that smart contracts are supposed to be immutable and that's the whole point, but to expect someone to implement a logic that never changes (no upgrade or no bugs) from day 1 is also ...
1
vote
0answers
108 views

Implementing a reinforced invoice?

I have a question. My contract structure involves 2 user at address A and B respectively: First A trigger the logging method from the contract with B's address as parameter. This will record a ...
1
vote
0answers
46 views

How to display information from one contract to another

I am trying to feed information in a contract and display it in another, I have 2 contracts provider and user: In Provider contract I am feeding information like name and address of a user, and I ...
1
vote
0answers
51 views

P to P assists exchange

We are building a POC with P2P interaction. It’s a prototype were 2 parties agree to exchange assets and the settlement is done. For above POC is it good to use global agreement contract or have ...
1
vote
0answers
333 views

To varify documents, how documents attached and who will verify and if miners how will they verify?

I need a help to develop a function to check the customer's eligibility /proof of identity. For example I am very very rich people (Practically NOT). Now i have decided to buy a big house in Las ...
1
vote
0answers
319 views

Abstraction and ACL in a smart contract

I have two smart contracts, say Admin and Subject. For this purpose lets assume that ten unique accounts have deployed 10 such Admin contracts. One Subject contract has been deployed which has a ...
1
vote
0answers
64 views

Avoiding congestion in large scale contracts

I have a contract that will implement a client/server-like functionality through the use of of events (peers have event listeners and make method calls depending on the events they are listening to). ...
1
vote
0answers
124 views

how can i make multiple users having different addresses when they register to my contract?

I want to create a register page where i want users to register and after registration they should get different addresses so that i can fetch their details by address.

1 2
3
4 5
7