Questions tagged [contract-design]

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

Filter by
Sorted by
Tagged with
0
votes
0answers
13 views

Implementation Question for Licence Token

I am currently working on the idea of using token as licences for digital products. I am offering different documents and books in pdf format and want people to be able to buy them with ETH o.ä.. I ...
0
votes
1answer
134 views

Abstract contracts cannot be initialised, can they?

As of v0.6, solidity introduced abstract contracts. Do they behave just like in all other languages - that is, they can't be initialised, can they?
3
votes
1answer
88 views

How does zocrates process zk-SNARK step by step?

I'm trying to understand my zokrates code and how it processes zk-SNARK step by step in accordance to this article. The article breaks down the zk-SNARK into three steps. A key generator, G, takes ...
0
votes
1answer
70 views

What are the flaws of this example contract?

I am currently writing a paper/article on tokenization, in the beginning of which I introduce smart contracts. To this end, I present the following contract as an example: pragma solidity ^0.6.0; ...
0
votes
1answer
60 views

Multiple transfers, one smart contract

I have the following function in my contract: function AcceptOffer() public payable { if ( msg.sender != InstanceOwner ) { revert("You are not the owner of this ...
2
votes
1answer
595 views

Destroy smart contract and collect its funds

I'm quite new at smart contracts/Solidity, which I'm learning for a postgraduate course. In one of the assignments, we have to implement a short example of dutch auction (wiki link). Now my question ...
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 ...
0
votes
1answer
503 views

Nested Structs with Mappings Inside

I have the following code: // SPDX-License-Identifier: MIT pragma solidity >=0.4.22 <0.7.0; pragma experimental ABIEncoderV2; contract VenueRegistry{ struct Queue{ uint head; ...
2
votes
1answer
35 views

Why can I call contract methods containing a selfdestruct multiple times?

The following code is part of a Smart Contract I'm working with: [...] function noComplain() allowed(receiver, stage.keyRevealed) public { selfdestruct(sender); } // function ...
1
vote
2answers
497 views

How can I get the revert reason of a call in Solidity so that I can use it in the same on-chain transaction?

I want to get the revert reason of a failed call and then use that revert reason in the same on-chain transaction. Is this possible?
0
votes
1answer
16 views

1-To-M struct relationship advice *DApp Development

Let's assume that I'm building a property investment DApp. I have two entities involved in the DApp. Those two entities are 1) providers and 2) investors. Right now, a provider is able to offer 1 ...
0
votes
0answers
27 views

TransferFrom - User Experience Examples

Can someone provide some DApp examples where the transferFrom pattern has been implemented and does an at least 'decent' job of providing a good user experience. If not, what is then a convenient way ...
1
vote
1answer
42 views

Accessing contract functions from web3 and javascript

I have deployed a contract in a private blockchain using remix and ganache. Now I want to interact with it trough web3 and the console from my browser, but I'm not managing to interact with the ...
0
votes
1answer
237 views

Receive ERC20 token as value in function of smart contract

I want to receive an erc20 token as value for a function. Basically, the function caller defines an amount which will then be transferred from their balance to the smart contract. Which transfer ...
1
vote
1answer
65 views

Can't people be tricked into calling approve on an ERC token contract, and having their tokens stolen?

Most users of Ethereum and ERC tokens probably aren't aware of the existence of the approve and transferFrom functions. Couldn't users unknowingly call approve on an ERC token contract, and ...
0
votes
1answer
49 views

Security flaws in a simple smart contract

I developed a simple smart contract to store two privacy preferences for a user. I am testing and evaluating this contract on a private blockchain via Ganache. I am currently validating the security ...
1
vote
1answer
33 views

Can you activate Contract Functions just by receiving Ether alone?

Noob Question here. I have a Dapp that has no actual need of a web interface. What is the best way to activate functions if someone did something as simple as send Ether to an address it controls from ...
0
votes
1answer
65 views

Card Game - Smart Contract (Public Cards)

We want to implement a card game with EVM and Smart Contracts. After defining all-important game information we asked ourselves how we can include the cards in the Smart Contract but don't make it ...
1
vote
1answer
90 views

Precompiled contracts

So I heard that the precompiled contracts perform functions that are difficult to do using EVM opcodes. Does that mean the precompiled contracts are not written in EVM opcodes. Which language are ...
0
votes
0answers
20 views

Which are the best and most secure multisend contract? [duplicate]

I am making a system where I need to withdraw funds from 1 wallet to 2 or more wallets at the same time. I have been looking for the solution to this problem, it seems like Multisend is the way to do ...
2
votes
2answers
79 views

A Captcha for Solidity Contracts

What is a good way to put the equivalent of a captcha in a Solidity contract? The objective is to put in a filter to make it difficult for bots to monopolize the contract, allowing regular humans to ...
1
vote
1answer
30 views

Explicitly conversion of addres and payable

i can't understand this Explicit conversions to and from address are permitted for integers, integer literals, contact types and bytes20. However, Solidity prevents the conversions of address payable(...
1
vote
1answer
26 views

How to get active users of Dapp [closed]

Is it possible to have unique constraint on parameters of an event? I will have a number of users using my Dapp, and I have provided functionality to delete the users. So while reading from the ...
0
votes
1answer
68 views

How do exchanges work internally?

Because EVM cannot watch events, we cannot send a token to an exchange and immediately get back some other token (EVM just does not "know" when it was send a token). As far as I understand, this is ...
0
votes
1answer
39 views

Can you force your smart contract to only process transactions in separate blocks

I am working on a smart contract and trying to come up with ways through which I can make sure that each transaction sent to my Ethereum smart contract is only processed as part of separate block, ...
0
votes
1answer
64 views

smart contract for fair exchange [closed]

Question: Is it possible to create a smart contract for fair exchange and investment: user1 sends ether to a smart contract which will multiply the amount by 2 and send it to user2. When user2 ...
0
votes
1answer
56 views

how to disable a contract by changing some internal state which causes all functions to revert?

In official documentation of Solidity about Self-destruct instruction is written: If you want to deactivate your contracts, you should instead disable them by changing some internal state which ...
1
vote
0answers
28 views

function overloads when the function is payable

I'm calling a function from another contract using an interface. The called function is payable and also overloaded. Example: contract OverloadedContract { function foo(uint x) external payable ...
0
votes
1answer
25 views

Mapping multiple structs to a struct and call them

I have a question about how I should design my contract to achieve the following: I want to create products identifiers (can be struct or string) something like: "product#123abc". Then I want to map a ...
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 ...
0
votes
1answer
72 views

Closed, Creating a method to airdrop ERC20 Token B to the holders of ERC20 Token A [closed]

I've been attempting some form of solidity code to automate the airdropping of Token B to the holders of Token A almost all day, but I still couldn't find much that works. How could I do this?
0
votes
1answer
55 views

Contract inheritance to share same storage in Proxy pattern for upgradeability

Please bear with me here, I have been trying to figure it out myself but couldn't. I am trying to learn upgradeability with a Proxy pattern .https://blog.gnosis.pm/solidity-delegateproxy-contracts-...
0
votes
1answer
18 views

Adding modifier for mappings

can I add a modifier (for ex: onlyOwner) to a mapping? only I must see the value of mapping's key by myself(onlyowner). For example: mapping (address => bool) onlyOwner getAddress; Thank you.
0
votes
1answer
105 views

Simulating multiple transactions

I want to simulate sending multiple transactions at the same time to a smart contract and i'm wondering if, for example, sending 100 transactions from one address is the same as sending 1 transaction ...
1
vote
1answer
233 views

Looking for code that makes this contract pay out dividends

I have used OpenZeppelin contracts to create a token in Remix that I can mint and send around: pragma solidity ^0.5.0; import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v2.5.0/...
1
vote
1answer
21 views

Puzzle- how to implement simple savings pool (via cDai) without iterating over unbounded loops?

Consider this example of a very simple savings contract, where users send Dai, which the contract converts to cDai. At any time users are free to withdraw their share of the accrued interest. I cannot ...
0
votes
0answers
21 views

How is the storage trie of a user account which does not belong to any contract?

We know that storage trie (stored in the leaf node of state trie) is storing the contract's data related to an account. Then, what will be stored in the storage trie of a user account which does not ...
1
vote
1answer
563 views

Is it possible to delete an ERC-20 token contract?

Is it possible, that someone creates a new token on Ethereum let it be XYZ, an ERC-20 token. Can he later call a destructor func that will wipe off all funds from all people that are using that system?...
2
votes
2answers
208 views

How to generate calldata for a function

I have got as far as generating the method ID for the function: function transfer(address src, address dst, uint256 amount); The method ID would be: bytes4(keccak256("transfer(address,address,...
1
vote
1answer
63 views

Solidity - selfdestruct doesnt work!

I implemented selfdestruct(), also it showed succeeded on Etherscan. Afterwards, I still am able to send transactions to the contract. Can you tell me why? Doesn't selfdestruct() delete the contract ...
0
votes
1answer
279 views

Searching for a value in a dynamic array

I understand that for loops on dynamic arrays are a big no no in Solidity, so I am trying to find an alternative to this problem. Goal: From a dynamic array of numbers, I am trying to extract the ...
0
votes
1answer
83 views

Lottery Winning number based on blockhash

After reading a lot of Info about this topic in this forum I am asking whether I can just use the formular winningNumber = uint256(blockhash(block.number-1)) % 100; e.g. 10 or 20 blocks after the ...
0
votes
1answer
109 views

What is the use of a interface or function without implementation?

Take, for example, this code. The interface contains function without implementation, so how it's useful. pragma solidity ^0.5.0; interface Calculator { function getResult() external view returns(...
0
votes
1answer
312 views

What is the core difference between send and transfer method of address payable in solidity? [duplicate]

I'm learning solidity I got two methods for transferring ether <address payable>.send(1 ether) <address payable>.transfer(1 ether) Both are used to transferring ether to the recipient ...
2
votes
2answers
421 views

How do Proxy Upgraded Logic Contracts Share Data

I have been looking at how to make my contracts upgradeable and looking through the Zeppelin docs and source code to try to wrap my head around this. One thing I cannot work out is: How do new logic ...
0
votes
1answer
19 views

How of should I migrate my Smart Contract?

I am developing a scraper which scrapes data and puts it on ethereum blockchain(ganache for dev) every week. So as to put this data onto the blockchain should I migrate my smart contract each time I ...
1
vote
1answer
92 views

Upgrading contract for modern compiler version

I am upgrading the old contract from 0.4.24 for new solidity compiler version 0.5.16 however it doesn't work with modern solidity compilers, Could anyone make my contract compatible with solidity ...
3
votes
2answers
117 views

Map or Array…?

I'm having a huge dilemma! I'm developping a smart contract that has, let's say Struct A and Struct B. Because I want to have a function retrieving all objects type A and B, I created a Struct All ...
2
votes
1answer
34 views

Whats the best way of translating this struct?

Let's say I must have this data structure: ├── Operations (struct) │ ├── date_begining (uint) │ └── date_end (uint) │ └── responsible (address) │ └── type **(?)** │ ├── Observation (...
1
vote
1answer
34 views

ERC20 coin transaction not successful

I called the mint function on a default coin to send some of my new coin to my METAMASK account but it looks like nothing was received. I can't tell what specifically could have gone wrong, so here's ...

1
3 4
5
6 7
36