Questions tagged [contract-design]

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

316 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
5
votes
2answers
459 views

How to access dynamic list from web3?

In my application players can create and join games. I store every game in a mapping(uint => Game), and send out a GameCreated event whenever a game is created. My issue is efficiently getting a list ...
4
votes
1answer
1k views

Reset all values in a mapping

I am trying to figure out how to have the balance of all players reset to (amount) when a certain condition happens. This is the function that will update a specific player balance. How do I make it ...
4
votes
2answers
569 views

Capturing an event fired from a contract that was called from another contract

I'm trying calculate tax on arbitrary items/values. To do this I have a single contract is used as an 'Oracle' to get the tax from an external system. This contract defines functions to be called from ...
4
votes
0answers
91 views

Ethereum Market Place Design

I want to model the following scenario - a small market place I have 2 nodes in my network - the seller and the buyer. I want to model the market place in that why - that the buyer node asks every ...
4
votes
0answers
81 views

What is the best way to implement the coin contract to get all coin transaction history?

What is the best way to implement the coin contract code to see all transaction history? It's easy to get the transaction history of ether, but it's kind of difficult to get all sending and receiving ...
3
votes
0answers
23 views

how do I know that NFT is from the right person

I understand the NFT (at least solidity part).. There's something that's bugging me though. Let's say someone made a super great cat(cat1), published it to ipfs, then called the ERC721 contract and ...
3
votes
2answers
745 views

How to generate a new token for ERC1155?

Developing an ERC1155 contract, how to generate an address for a new token? I need to create an API function like function createToken() returns (address). How? Should I just use an incrementing-by-...
3
votes
3answers
1k views

How to handle dynamic size string array in solidity?

I have a shop owner and a shop owner can have multiple products. I want to keep the products id in an array. Also, A public method can return all the product id list of a shop owner. I tried the ...
3
votes
1answer
132 views

ERC20 with custom sale mechanisms?

Let's say I want to create a token, but I don't want this token to be exchanged too freely, in order to avoid too much of speculation (real estate for example). People willing to sell the asset will ...
3
votes
1answer
474 views

Loop with optimal gas usage

I currently have the following loop (some stuff left out) mapping (address => uint) pendingWithdrawals; function example () private{ address[] tempList = List; for(uint k = 0; k < ...
3
votes
0answers
235 views

Benefits of library versus a plain contract (upgradeability)

I'm trying to find what the benefit is of a library. I found the following statements. (Please correct me if i'm wrong) Cost less gas to deploy Uses the storage of the calling contract the library ...
3
votes
0answers
141 views

Identity valuation using smart contracts

Hi I'm currently exploring whether it makes sense to build a platform which would use a blockchain to verify a user and the data that they would add to the platform. Very simple example would be ...
3
votes
0answers
2k views

How can we lock an ERC20 token in a contract and generate another ERC20 token proportionally over the locked duration?

"Gnosis tokens (GNO) are the generator for Wisdom token (WIZ) creation. WIZ can only be created via activating the utility of the Gnosis (GNO) tokens. This is done via a smart contract system. The ...
3
votes
0answers
1k views

Is this approach to an ethereum lottery sound and/or novel?

I'm looking at making gambling apps is ethereum. Currently made a contract that can flip a coin. After looking at this question: How can I securely generate a random number in my smart contract? and ...
3
votes
0answers
471 views

Ethereum and child chains like NXT/Ardor?

Doing some research on how we can implement this type of system with ethereum smart contracts. Currently the upcoming Nxt/Ardor system implements a child chain system where the main chain deals with ...
3
votes
1answer
2k views

What is the burn() and burnFrom() function in EThereum Token Creation contract?

Please find the below ethereum token creation contract. It has two burn functions. It is having redendent params also. Why it is placed, what is the importance of the functions. pragma solidity ^0.4....
2
votes
0answers
43 views

solidity math overflows

function nice(uint8 x) public returns(uint8 z){ uint8 z = 0; z = z + 240; require(z = z + x, "overflow"); } I have been using this code with the solidity versions, ...
2
votes
1answer
44 views

how do we use `commit/reveal` to count votes?

Let's say we are doing an election and it's easy to note that we need commit/reveal scheme to hide votes. So, we store hashes while users commit their votes. Now, let's say the election is over. How ...
2
votes
0answers
41 views

Is gas cost of external calls included in gas cost of the main call?

When I call external methods of other contracts from my contract, is the gas fee of these calls included in the gas fee displayed by MetaMask? My transaction reverts (execution reverted) for an ...
2
votes
0answers
32 views

Are there well-solved patterns and practices for handling errors in Solidity?

In the spirit of Are there well-solved and simple storage patterns for Solidity?... Are there known, battle-tested practices for how to deal with errors in large Solidity codebases? It's common in ...
2
votes
1answer
289 views

Token Swap From Ethereum Host Network To Different Blockchain

What is a good way to swap tokens from the Ethereum host network to a different network (i.e. the Tron blockchain)? Would the best way to do this be to have a smart contract where ERC20 token holders ...
2
votes
0answers
48 views

How to get a call graph for the binary code of a contract?

I need a call graph generator for the assembler level of smart contract code in order to analyse solidity compiler bugs. In that way, porosity is excatly what I need ! However there are too much bugs ...
2
votes
0answers
27 views

Name Styling Best Practices Internal/External variables/functions etc

The solidity docs clearly specify how to style function order, types etc. However, are there an appropriate way to also separate between internal/external variables, functions etc. I see some people ...
2
votes
2answers
116 views

To transfer tokens from owner address to an address, if latter address moves some other tokens to a given particular address

I am writing a contract for an ERC20 token (say ABC). Is it possible to airdrop some of these newly minted ABC tokens to those ERC20 addresses, every time, if they transfer a different token (named ...
2
votes
0answers
176 views

How the following pairing equality be verified in Etherum Smart contracts?

I have found available precompiled contracts in solidity. For example, this answer enter link description here points out a precompiled contract that can verify BLS signature. However, looking to the ...
2
votes
1answer
115 views

bn256 and Boneh-Boyen digital signature in solidity

I am looking to have a full-fledged implementation of bn256 in solidity. And Boneh-Boyen digital signature. Is there is any available built-in libraries or implementation in solidity to bn256 and ...
2
votes
1answer
239 views

Call a payable contract's function from another contract via an interface

I have two contracts, they are connected via an interface. When user calls contract1 function, it uses an interface to call contract2 function which updates it's storage. My problem is that I can ...
2
votes
0answers
51 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 "...
2
votes
0answers
59 views

Is returning an array of structs possible yet?

From what I can tell this should be possible now: function test2 () public view returns (Post[]) { Post memory post; post.sender = msg.sender; post.link = "test"; ...
2
votes
1answer
88 views

How does Ethereum know who called a function first?

Scenerio 1 Say I have a function f(). Whoever calls the function first gets a reward. Persons A, B, and C all call the function at roughly the same time. Who will receive the reward? Scenerio 2 ...
2
votes
0answers
151 views

Is there a comparison of Ethereum smart contracts to other platforms that also have smart contracts?

Doing some research in the smart contracts arena. But is there an in depth comparisons with the pros/cons of each implementation of smart contracts in other blockchains as compared to Ethereum smart ...
2
votes
0answers
68 views

Can Smart Contracts be used to execute trades on exchanges?

I'd like to create a smart contract to execute trades on exchanges and transfer the received ethereum to another wallet. Something like this: * Receive token into wallet * Smart contract sells token ...
2
votes
0answers
147 views

Succinct contract state/storage root of a smart contract

In the yellow paper, it is mentioned(at section 4.1) that storageRoot: A 256-bit hash of the root node of a Merkle Patricia tree that encodes the storage contents of the account (a mapping between ...
2
votes
0answers
243 views

Alternative solution for loops in subscription smart contract design

I am a new developer, working on a smart contract mostly for my own learning. I am developing a Smart Contract to handle subscriptions. The contract has the below features. Subscribers can subscribe ...
2
votes
0answers
57 views

Smart contract state storage under the hood and scalability

I know smart contract state is being added in block, Does this true always ? When I add or update an array of struct in contract what happens under the hood ? Is there any limit for such data ...
2
votes
0answers
351 views

Limitation on amount of data that can be sent on Geth

We are creating a small private network with the purpose of sharing data. We thought that the main concern about writing large amounts of data in Ethereum would be the gas cost, which is not a problem ...
2
votes
1answer
230 views

Contract creating other contract doesn't show resulting transaction details on etherescan

Looking for help with a successful transaction not showing the details on etherescan. Having a deployed factory contract like so (simplified): contract EntityFactory { event EntityCreated(...
2
votes
0answers
249 views

Usage regarding for loop in solidity contract

I am trying to integrate for loop in my smartcontract for adding details to a struct. I have implemented for loop using frontend by calling the function in smartcontract one by one. struct details {...
2
votes
0answers
478 views

Do we have to have a fallback function in our smart contract?

I have a smart contract that has only one payable function and one that pays, as follows: contract DAO_Test{ // define something function buyToken() payable external returns(bool){ ...
2
votes
2answers
135 views

How to make users trust my contract and me?

I bought a ticket to attend StrangeLoop 2017 (IMO, one of the best conferences out there), but something came up and I can no longer attend. Since I'm learning about Ethereum, I thought it might be a ...
2
votes
0answers
133 views

Nesting Design Pattern given Solidity Limitation

What I have so far I have a Validator contract that is supposed to insert a key-value pair in the database contingently on a particular invariant being satisfied. contract Validator { DataBase ...
2
votes
0answers
91 views

How does the increasing array size affect contract throughput?

I was working with arrays in my contract and I came across the fact that I'm deleting the middle element from an array and because I don't want to ruin the order I don't shift the last element to the ...
2
votes
0answers
234 views

Can successive confirmation length blockhashes be used to generate an effective random number?

I've been trying to make a random number generator that doesn't need to be outsourced like Oraclize or break down at scale like RanDAO where n deposits gives 2^n possible manipulations for the random ...
2
votes
0answers
96 views

How is Ethereum integrated into real world (situations)?

For example, there exists a smart contract for marriage, known as I want half. Does the corresponding property have to exist in Ethereum too? Where will the contract gain knowledge about the IRL ...
2
votes
0answers
913 views

TypeError: Cannot access member 'code' of undefined

I am new to geth command line for testnet in Windows. I got an error when trying to deploy this contract example ---------------------------------------------- source = "contract test { function ...
2
votes
0answers
235 views

Error in dapp developed using 'Truffle' framework -Smart contract function call won't get executed

I am developing a dapp using 'testrpc' and 'truffle'.I have also used ethereum-bridge for Oraclize.I have written a smart contract function which calls a url using 'OraclizeQuery'. The following is ...
2
votes
0answers
487 views

What is the simplest way to allow a contract to pay for gas?

EIP86 and abstraction discussion is exciting for the future, but what are the things we could change first, to allow a contract to pay for gas? For example, for the withdraw transactions on BabyZoE, ...
2
votes
0answers
89 views

returning bulk data

So I was wondering If it's possible to return bulk data. What I mean with that is returning everything (or part) from an array. I know the following is not possible (correct me if I'm wrong) Array of ...
2
votes
0answers
342 views

Using contract balance as gas/tx fee for external call

Currently I have a hosted wallet Solidity contract as described below. It has a execute() method that calls another contract from a hosted wallet. However looks like call() uses the balance of the ...
1
vote
0answers
11 views

how to decode/encode ipfs for contracts

It's known that IPFS can use 2 types of CID, v0 and v1. In my contract, I let users store bytes data parameter. They can store some simple text on it or even pass the ipfs hash. This question is about ...

1
2 3 4 5
7