Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.

Questions tagged [contract-design]

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

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

Solidity: Is there any way to store the start time of solidity code? now() function returns block.timestamp only

I wanted to get a start time of solidity code, so I used now() previous which only returns block.timestamp whenever the solidity got started. Is there any way to store or know the start time of ...
0
votes
0answers
18 views

How to build a P2P wager contract with Solidity

I am looking to build a contract with Solidity that will take wagers on a football game between a bunch of friends. Each user should be able to place a bet on either team, with each bet to be added to ...
1
vote
2answers
31 views

loop though all the members of a map

I need to loop though all of the members of a map and change their property (which is a struct). the way i'm doing this is when adding a member to the map object also save it's address inside an ...
1
vote
1answer
22 views

How do you implement a front-end contract with back-end functionality in Solidity?

How do you create a front end contract that calls a back end with the idea of being able to upgrade or change the back end contracts without having to redeploy the front end contracts?
0
votes
3answers
17 views

Emitting Transfer Event even when there is no actual transfer

I am new to smart contracts and trying to understand it so that i can detect Ether transfers done to my user via Smart Contract. I know I can find the event emitted from topics[]. But for those ...
1
vote
1answer
10 views

Many-2-Many ERC721 Pattern?

I'm looking to build a smart contract with a function which is able to generate a unique and limited amount of ERC721 tokens based on an input string. I also want to be able to look up all the tokens ...
0
votes
2answers
34 views

Solidity contract reentry attacked

The idea is to have a user call send() with some eth. The contract decides if user won/lost. Winner gets a prize msg.sender.transfer(msg.value + winnings); loser gets nothing. Unfortunately the ...
0
votes
1answer
25 views

How Do I Write a Smart Contract to Put a Bounty on Something? [closed]

For example, if I want to send 1 ETH to the first person to beat the Guinness world record of push-ups in one minute, how do I do that? What if I want to send the 0.001 ETH to someone for routing a ...
0
votes
1answer
14 views

How to substitute attributes instead of roles in access control coding for solidity?

Say, the role-based access control consists of two roles. But if I want to replace the roles to maybe location and time, how to go about it?
0
votes
0answers
19 views

Can a dapp/smart contract execute a transaction based on a private github file modification?

Scenario Suppose someone promises to deliver code to a private repository, that person is so sure they will, that they even said: "here is x eth, if I don't deliver in time, send the x eth to a ...
1
vote
1answer
17 views

Two calls to a contract: input of the first can only be revealed after the second call

I see that there are no parallel execution in EVM. The problem I am trying to solve is the following: I have a contract which takes the input of two parties -- say users A and B. The result of the ...
0
votes
2answers
16 views

How to get the result by parsing the log after executing the contract? How can I get the execution result?

How to get the result by parsing the log after executing the contract? How can I get the execution result ?
0
votes
1answer
28 views

Desired Revert if Condition Is True [closed]

What is the best way to revert inside a function if a particular condition is true? Sometimes safeguarding with require statements is not enough, i.e. uint256 constant public OFFER_LIMIT = 500 ...
0
votes
1answer
27 views

Memory Utilization Pattern Solidity?

I was wondering what is the most efficient way (and why), to use variables in memory for function calls with regards to A and B? A) Like this: function checkBalance() public view returns (uint256) ...
1
vote
1answer
33 views

Add Number to Item in all Struct Members

I have a struct where I want to increment an item across all struct members. For example, say there is a struct 'Contract', and new customers get their own bytes32 ID, which points to their own struct:...
0
votes
1answer
18 views

Need to enumerate keys of a mapping [duplicate]

I have a directed multigraph of courts "trusting" each other: struct TrustedCourt { uint256 courtId; mapping (uint256 => uint256) limits; // intercourt token => amount } ...
2
votes
2answers
30 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-...
0
votes
0answers
11 views

Why are there non-batch transfers in ERC-1155?

Why are there non-batch transfers in ERC-1155? Why not the API only for batch transfers? It would make contract codes shorter and thus simplified contract development and saved gas.
0
votes
0answers
9 views

Where to specify the spent limit?

I am creating a contract representing a court. A court can add an arbitrary amount of crypto to any account of its choice. (This is what a court is intended for.) It looks reasonable to assign a ...
0
votes
0answers
12 views

What is operator approval in context of ERC-1155?

https://github.com/enjin/erc-1155/blob/master/contracts/ERC1155.sol says something about "operator approval". What is an operator and what is operator approval?
0
votes
2answers
19 views

One or multiple owners?

My contract is controlled by owner(s) who can decide to discharge the money from it. The owner also can assign another owner, set spending limits, etc. Should the contract have one or several owners? ...
0
votes
1answer
37 views

Error Handling on Contract Calls to Other Contracts

I'm trying to call a function from another contract and need a way to accommodate errors. Say contract A has the method getBalance: function getBalance(address x) public view ...
0
votes
1answer
27 views

How does Ethereum's Makerdao Dai stablecoin differ from EOS's Equilibrium EOSDT stable coin?

What are the main differences from Ethereum's makerdao dai stablecoin to EOS's equilibrium EOSDT stablecoin? And are there other stablecoins like these two that are decentralized and issued via a ...
0
votes
0answers
34 views

Comparison of 2 child-contract-values in factory-contract

in my solidity code I create a tracking-contract and auction-contracts out of a factory-contract. The last function 'a4_Payment' of the auction-contract should be triggered out of the master-contract ...
0
votes
0answers
18 views

Can a factory-contract access/read/modify variables in generated child-contracts?

at the moment I am experimenting with the factory/child-logic in solidity. With my factory contract I am able to create child contracts in which an auction is executed. Now I want to return a variable ...
0
votes
2answers
29 views

Could I implement a kill switch in my solidity program?

I was wondering if there was a way to put a killswitch into my solidity code? I am using v0.4.21+commit.dfe3193c Thanks a bunch!
2
votes
0answers
15 views

Why is it required to know the function selector in a smart contract to call the function? [duplicate]

I understand what a function selector is and how it is computed: The first four bytes of the call data for a function call specifies the function to be called. It is the first (left, high-order ...
0
votes
1answer
17 views

Query each struct of a Mapping vs looping getter function for front-end?

I have a mapping of structs and a counter variable to keep track of how many structs are stored in the mapping. For front-end development would you recommend to query each struct using the auto-...
0
votes
1answer
25 views

Keeping a finite set of addresses (Solidity)

struct Data { ... } contract Court { mapping(address => Data) subcourts; } I want to keep track of a small finite set (which can be added or removed) of all keys of this mapping. What is the ...
0
votes
0answers
11 views

Auction Contract with “Right to Bid”

I build a basic reverse auction you see here using Solidity and the ethereum remix IDE. In addition to the functionalities already implemented I would like to add a "SafetyLimit" amounting to half the ...
0
votes
0answers
13 views

How to find out in blockchain ledger the current ownership of asset being transacted

I am new to blockchain and smart contract as well. In smart contract we can only save the current state of any transaction but if we need to know the previously expunged transactional data ie, the ...
0
votes
2answers
21 views

validation of data integrity in block

I am learning ethreum dapps development and have developed some dapps. I was thinking about supply chain dapp which i think , is very good application of blockchain as it ensures all the history of a ...
2
votes
0answers
22 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 ...
0
votes
2answers
33 views

How to disable a function from a parent contract?

Say I have this contract: contract Foo { uint256 public foo; function setFoo(uint256 _foo) public { foo = _foo; } function setFooToZero() public { foo = 0; } } ...
0
votes
1answer
33 views

Ethereum 2.0 (Serenity) & PoS

I understand that the underlying consensus model changes from PoW to PoS. However, will it also result in changes to how wallets interact with the network? Will transaction fees still have to be paid ...
1
vote
1answer
39 views

Transactions and smart contracts during reorganization

I learned from this question that transactions will be reverted and rollback after chain reorganization. But after a transaction is reverted, will the sender needs to resend this transaction? Or this ...
0
votes
0answers
35 views

Smart contract function not returning value (decoded output) in Remix

I am completely new to Solidity and would appreciate any help. I have a supply chain smart contract and it contains a function that is supposed to be called by customers and after the call, the ...
0
votes
0answers
26 views

Fetch ETH USD Rate from past using Oracle

Is it possible to fetch the USD rate of ETH at a specific time in the past to a smart contract from an external API using an oracle? i.e. I have a function which tracks whether now > start + 10 ...
0
votes
1answer
18 views

Storing a monero address in smart contracts?

Assuming I would have to store Monero addresses or any cryptonote based coins addresses in a smart contract, would there be any issues? Consider that those addresses are as long as this random ...
7
votes
2answers
77 views

Pros and Cons of smart contract upgradable patterns

There have been quite many arguments around how to achieve smart contract updates like Upgradeable smart contracts. I feel Proxycontract with Delegate-call is currently the most famous one. But aside ...
0
votes
1answer
21 views

How can I use Ethereum smart contracts with another crypto currency?

I am learning/playing around with some concepts of the blockchain, smart contracts and Ethereum. I have created my own "toy" cryptocurency ("myCoin") by forking a coin using the CryptoNote algo. I ...
0
votes
1answer
29 views

Are there any good ways to express conditional ownership on ERC20 or ERC721 tokens?

I'm currently looking for any good ways to express conditional ownership on tokens. I look into approve function of both ERC20/ERC721 but, it seems that function may be disapproved by the owner and ...
0
votes
0answers
38 views

How to print the value of a Struct ?(mapping)

If the set function receives two inputs 1.["0xca35b7d915458ef540ade6068dfe2f44e8fa733c",50,"ROC","park"] 2.["0x14723a09acff6d2a60dcdf7aa4aff308fddc160c",60,"AU","school"] How do I display the ...
0
votes
0answers
19 views

Is there any for a contract A to directly read the value of another contract B , while B doesn't necessarily have any getter functions

The following codes is a function of contract B, how can a contract A get these values such as balance[from], balance[to], balance[msg.sender] as efficiently and directly as possible in contract B ...
0
votes
2answers
43 views

Am I Generating Random Numbers In A Non-Mallable Fashion?

Would this be a non-malleable way to generate numbers for my particular use case? Let me explain: I allow people to register for a lottery-type event. If a winning seed belongs to their ticket set, ...
1
vote
1answer
22 views

Are there identifiers for smart contracts?

Say I want to reference another smart contract in my smart contract. Do smart contracts have an identifier (like a number 0xjdjdjdjdjjddj etc.)? And if they don't, how would you reference a ...
0
votes
0answers
13 views

Random Number Generation, Appropriate case or no? [duplicate]

I'm building a lottery where I need to generate a list of random numbers. Basically, I have a group of people who will commit to a prize by staking a certain amount of tokens to their commitment - ...
1
vote
1answer
77 views

VM error: revert. revert The transaction has been reverted to the initial state. Note: The called function should be payable if

Hi Guys 👋 I have two contacts first one is SubToken and second one is MainContract. First I deploy MainContract after that I use createNewContract function and I create new SubToken. and then I ...
1
vote
1answer
55 views

Web3 - Assign nonce to smart contract transact

I have a smart contract. I want to execute one of its state modifying functions. This is the code: const result = await smartContractObject.methods .addSomething(_valueToAdd) .send( { gas: '...
1
vote
0answers
40 views

Error: Operator << not compatible with types bytes1 and int_const 1 return b10 << 1;

I don't know how to correct the code of function 4 & 5. pragma solidity ^0.4.4; contract C { bytes1 b10 = 0x6c;// l-> 0110 1100 6c转换为10进制-》12*16^0+6*16^1=108 bytes1 b11 = 0x69; ...