Questions tagged [design-patterns]

A design pattern is a general reusable solution to a commonly occurring problem in software design. Use this tag for questions when you're having problems with the implementation of design-patterns. Please don't use this tag on questions about text pattern matching. When using this tag on implementation heavy questions - tag the code language the implementation is written in.

Filter by
Sorted by
Tagged with
0
votes
1answer
23 views

How do you pause a Proxy-Logic pattern?

Suppose we have a Proxy contract that forwards to call to a Logic contract by using delegatecall. If we pause the Proxy, users will still be able to directly interact with the Logic contract. While ...
0
votes
2answers
27 views

Split State Storage Contract

This is a follow-up question of Split Contract Design Pitfall Background: I have split my logic into two contracts A and B. A keeps the state and not ETH. All state change functions are only allowed ...
1
vote
2answers
204 views

Reason for check of msg.value > 0

I came across published smart contracts (like this one from ConsensSys) that check whether msg.value is strictly larger than zero in their payable functions. After wondering whether msg.value can be ...
0
votes
2answers
35 views

Self Destruct Design pattern - Loss of funds issue

I was exploring on self destruct design pattern for a time bound smart contract. So my contract should not accept any further state change after a certain given time period. While working on that I ...
1
vote
1answer
83 views

What is the Withdrawal Pattern?

I am reading this article : https://medium.com/@jgm.orinoco/why-use-the-withdrawal-pattern-d5255921ca2a It seems interesting. Could anyone explain the idea of the Withdrawal pattern in a simple way ?
1
vote
1answer
70 views

Design pattern Checks-Effects-Interactions Pattern

I was workig on design pattern Checks-Effects-Interactions Pattern and found the below link which has a similar question but in the direction which I am looking at .. Checks-Effects-Interactions ...
2
votes
1answer
369 views

Issue in type conversion : Explicit type conversion not allowed from unit256 to bytes1

I am trying to convert the unit to string using the method. I have the "TypeError" in the line. Please check the screen shot below for the error message. function uint2str(uint i) internal pure ...
0
votes
1answer
42 views

Circular reference error in factory contract pattern

I've used the factory model before, but I've never encountered a circular reference error, and I'm having trouble seeing how this could be a circular reference when I'm creating a brand new ...
1
vote
1answer
40 views

Solidity/Remix Error: The constructor should be payable if you send value enum change state

I'm using this (State Machine) design pattern in solidity and having an error when changing the state after executing the first function. Any hint? Thank you! Error: revert The transaction has been ...
0
votes
0answers
25 views

Microservices for Quorum/Ethereum - Deconposing and splitting the monolith

While implementing the microservice architecture pattern, I discovered that ethereum/quorum, if decomposed/split further as per microservice design, scalability will improve by a significant margin. ...
0
votes
1answer
93 views

Design pattern for game development

I am developing a game which currently uses a GameFactory contract to create instances of a Game contract. The Factory pattern would allow any number of players to play their own single player game ...
0
votes
2answers
116 views

What is the proper pattern to use a temporary variable and ensure it gets stored?

A contract has a state variable, which is complex. For the example, lets say it is a mapping of structs. Inside a method, I want to access that and store the changes. Like so: contract FooManager { ...
0
votes
1answer
68 views

Production Fork of Ethereum

everyone! I have a project, where I surely need to implement transparency of all the actions doing in the network. Let's say I want to create public asset tracking. So everybody who posts an asset in ...
0
votes
1answer
173 views

How can contracts share a whitelist?

I have a token, let's call it TokenA, that inherits from Open Zeppelin Whitelist.sol. TokenB and TokenC both inherit from TokenA and they each have some additional functions. I want all three Tokens ...
0
votes
0answers
14 views

Why is it important to defend a contract against reentrancy? [duplicate]

As stated. I have seen a number of threads about the how-to's on guarding a contract against re-entrancy. But in terms of best practices, security and risk-avoidance, WHY is it important to do so? (...
0
votes
1answer
127 views

How to identify submitted transaction to network?

I am developing an eCommerce application that has on-chain and off-chain components. The off-chain components focus on the compute and storage intensive operation while on-chain smartcontract ensure ...
0
votes
0answers
28 views

Why is Checks Effects Interactions pattern called Checks Effects Interactions pattern?

Why is Checks Effects Interactions pattern called Checks Effects Interactions pattern? Perhaps External interactions Pattern or External Call Pattern is a better term? In short this pattern is ...
1
vote
0answers
98 views

What is a common pattern to work with a large number of complex Things: make a Thing a contract, or a struct in a mapping?

In order to build a somewhat complex Dapp, I need to manage "Contributions". To do this, I roughly see two patterns: A Factory-pattern, in which each Contribution is it's own Contract/Instance. A ...
0
votes
0answers
116 views

Listen for Solidity Event With X Number of Confirmations

I presume Solidity events are fired the moment the block that includes its transaction is mined -- please correct me if I'm wrong. I need to sync the transaction status locally but wish to only save ...
0
votes
1answer
49 views

Why lot of Smart Contract implementations are using a single instance to hold all accounts?

I found a lot of example of tokens (like ERC20) using this pattern: contract MyCoin { mapping (address => uint) balanceOf; ... } Those contracts are deployed once, the "balanceOf" ...
3
votes
1answer
243 views

Oraclize __callback function with unbounded gas usage

I am making a lottery contract and using Oraclize to select a winning number. Here is what I have now: The owner calls a finalize() function, which disallows new entries, and makes a call to ...
1
vote
2answers
55 views

Withdrawal pattern in fallback function

I need to implement withdrawal pattern for my smart contract. I wanted to make it possible to interact with contract for the people, who use smartphones and tables, just by sending some amounts of ...
2
votes
0answers
40 views

Where does Ethereum Dapps go in known design paterns

I am doing a Dapp for a school project and I am supposed to choose a design pattern to work with. I want to know the possibilities for design patterns concerning the ethereum dapps, or if they have ...
3
votes
4answers
873 views

Should UIs handle 4Byte signature collisions

With 4 bytes collissions are possible. But they are not very likely. Currently in the 6,846 signatures in the 4Byte.direcory there are no collisions. Still they are possible. Now I wonder if UIs ...
1
vote
1answer
23 views

Are there any downsides to if…else logic versus rejecting in a function

Pretty much all examples of contract functions I see use the require(...) pattern. If the initial condition is not as expected, an error is thrown and the transaction is reverted. I don't like this ...
1
vote
0answers
27 views

Build blockchain application that has some off-chain functionalities

I am learning about blockchain and I have a general question. Let's say that I want to build my custom blockchain based on Ethereum. My implementation has many nodes and few of them are chosen ...
0
votes
1answer
181 views

Web wallet best practices

I'm putting together an ether/erc20 token wallet in a chrome extension but would like to follow best practices with regards to private key security. I'm using localstorage to handle login and its ...
0
votes
1answer
88 views

Modeling language for Block-Chain-Oriented Systems

Any ideas about how do i use graphic models for representations. Should i follow UML diagrams style?
0
votes
1answer
119 views

Solidity local validation call before sending state changing transaction

I have an use-case where the user should be able to change a contract's state only when the inputs pass a validation check. However the validations are expensive to perform and can be done locally ...
2
votes
1answer
415 views

Is there a way to return data from a fallback function?

I'm trying to write a contract that contains a fallback function which would pass-through the call to another destination contract. This would allow for future upgrades/bug-fixes to the destination ...
2
votes
0answers
108 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 ...
5
votes
1answer
144 views

Is the Ethereum client Javascript API supposed to be publically available? [duplicate]

I am still trying to understand the Ethereum design, and one thing I can't work out is if all Ethereum nodes are supposed to expose the JavaScript API and if that is supposed to be publically ...
5
votes
5answers
2k views

Need help to break down large contract

related to question Best practices to solve the problem of a contract that is too large?, I am facing similar issue (contract too large to be deployed, compare to gasLimit of the blockchain) and ...
2
votes
0answers
57 views

Updateable contract design: Database contract only accessible through setters and getters? [duplicate]

Hey I'm designing a Dapp that has a database contract and a contract with the logic side. The only way I can see of making this work is through having the logic contract make a call to a getter or ...
3
votes
0answers
542 views

Does this architecture violate a Dapp-philosophy?

Sorry for my English, again... First I wanted to place this post on Etherium Reddit. If it needs to be there, just close this question... I need to implement this logic: From Wallet 1 user ...
4
votes
2answers
125 views

Is there an advantage rollbacking the transactions with 'throw' over returning an error code?

Most of the code I read out in the wild follow the precondition pattern if (condition) throw; But this approach is cumbersome for clients to read. For example, with web3js you would have to check if ...
7
votes
2answers
205 views

Avoiding ownership cycles in contracts

I am repeatedly facing this issue with structuring contracts' code: contract Allower { Allowed allowed; function doSth() onlyallowed; modifier onlyallowed { if (msg.sender != ...
5
votes
1answer
138 views

How to implement the “unique address per customer” design pattern, often used with Bitcoin?

With Bitcoin, it works because of the joinable UTXO's , like this: Generate a key pair for each customer, and associate the public address with the customer id. Receive payments from multiple ...
1
vote
0answers
536 views

How do we design identity management systems in Ethereum? [closed]

I’ve read Ethereum will make possible cryptographically verifiable identities that are integrated with the Ethereum client, and thus not requiring any password or logins. Does this presuppose the the ...
4
votes
0answers
124 views

How is Casper better than POW against possible government censorship? [closed]

As of now my understanding is that with POW an attack by one or multiple goverments could be orchestrated just by raiding mining farms (which can be easily identified given the electricity bill) and ...
150
votes
12answers
31k views

Upgradeable smart contracts

If the contract issuer wants to have a way to upgrade the contract code, so that account data and other things carry over, can Ethereum provide for this? Also can this be done without changing the ...
5
votes
1answer
274 views

Contracts as First Class Citizens

I understand a contract being described as a top level abstraction, but what are some architectural and design advantages (and disadvantages) for developers in isolating their design classes into ...
3
votes
1answer
440 views

How do I make a Dapp that orders pizza?

So I recently purchased ether.pizza with the intention of setting it up so people can order pizza with ether just to use as an experiment in Dapp and contract development. Initially I plan on just ...
13
votes
3answers
2k views

What design patterns are appropriate for data structure modification within Ethereum smart contracts?

I am looking to hear about design patterns that people have implemented within Ethereum smart contracts to allow for post deploy modification of data structures. For example, say I have a contract ...