Questions tagged [contract-design]

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

Filter by
Sorted by
Tagged with
2
votes
1answer
216 views

Geth bug when working with address arrays?

I have the following contract that handles address arrays: contract C { address[] goodAddr; address[] badAddr; function initAddr() constant { if(goodAddr.length == 0) { ...
2
votes
2answers
365 views

Solidity Math: What's wrong with the function

What is wrong with the math logic in the function? It shorts the supply of tokens and it distributes much less than expected. if the contract owns 1000 tokens and the total ether fund size is 30 ...
2
votes
0answers
52 views

What is a suitable pattern for building a web/mobile app that leverages ether? [closed]

Noob to ether dev. Looking to understand how to build an app that leverages Ethereum - what suitable patterns are out there (ideally to go via some tutorials). A few apps examples (from easy to ...
2
votes
2answers
262 views

Is it possible to interact with a contract deployed within another contract via web3js?

Be very helpful to know if the scenario below is possible contract A { import "./B.sol"; ... address c = new B(); b = B (c) } //somewhere in JS instance_of_B = web3.eth.contract(B.abi).at(c);
2
votes
1answer
32 views

where does function variables get created?

function element() public returns (uint) { uint test = 20; return test; } Where would test variable be created ? in memory or stack ? The funny thing is from testing assembly, I can see that it'...
2
votes
1answer
1k views

Event Log in Solidity

I noticed the following behaviour of event Log and wanted to confirm if that was the way it is supposed to work. Code below. Function create requires two fields. I put "require" in place to check ...
2
votes
2answers
204 views

ETH - Pre-Paid smart contract so users don't pay transactions

I'm developing a "corporate" DApp, therefore the employees don't have any reason to "spend" their ether/gas for interacting with the contract... Is there any way to enable each ...
2
votes
2answers
303 views

Why do people hash the address?

I recently saw a smart contract where the user used keccak256(address), is there any reason to do this, instead of just storing the address in the mapping?
2
votes
2answers
3k views

Error Encoding Argument (remix)

We have a contract as follows: pragma solidity 0.4.23; contract RFID { struct StateStruct { bytes32 description; mapping(bytes32 => bytes32) sub_state; ...
2
votes
1answer
1k views

How To Call Multisend Contract

If I have the contract with the code contract Airdropper is Ownable { function multisend(address _tokenAddr, address[] dests, uint256[] values) onlyOwner returns (uint256) { uint256 i = 0; ...
1
vote
2answers
275 views

Who is msg.sender in a nested call chain?

I read about who is msg.sender when calling a contract from a contract, but who is msg.sender when calling a contract from a contract that calls another contract and so on and so forth?
1
vote
3answers
328 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?
1
vote
1answer
233 views

contract inline assembly - return array parts by using assembly

I've a couple of questions. mload function returns the data that resides on the address we pass to mload. Is this correct ? add function is used to give us the address from 0 to whatever we pass. ...
1
vote
0answers
23 views

why mload(0) returns wrong number?

int x; // Storage slot #0 mapping (uint => uint) y; // Storage slot #1 uint [] z; // Storage slot #2 function element() public returns (uint a, uint b, uint c) { z.push(45);...
1
vote
0answers
21 views

why do i have to specify memory in arguments?

My function body looks like this: function element(uint a, uint b, uint[2] memory c) public returns(uint e, uint f, uint g, uint k) { I am wondering why do I put memory keyword before c ? I know that ...
1
vote
1answer
75 views

sload. assembly with struct - not working in solidity

struct S { uint128 a; uint128 b; } S test1; function assemblyStorage() public returns (uint a, uint b, uint c, uint d, uint f, uint g){ test1 = S(5,10); assembly { a:=sload(0) } } ...
1
vote
0answers
64 views

how do storage and memory variable work?

So, in an ordinary programming language, we have stack and heap. Reference types such as array gets stored in heap. and the variable which holds the address(pointer) of this array is stored in stack.. ...
1
vote
2answers
256 views

Solidity, is it possible to deploy a smart contract that prevents other smart contracts from inheriting from it?

I am new to Ethereum and I was wondering if it is possible to deploy a smart contract such that other smart contracts are not able to inherit from it. In other words once a smart contract is deployed ...
1
vote
2answers
2k views

Solidity: How could I apply delete to complete storage ref[] with one call?

Definition: mapping(address => data) clusterContract; struct data { //defined inside a Library. mapping(address => Library.Struct[]) my_status; } data list; ...
1
vote
2answers
137 views

Split Contract Design Pitfall

Due to out-of-gas during deployment, I plan to split one large contract into two: contract A to keep state and is not meant to store any ETH, any state change functions are modified to be allowed to ...
1
vote
1answer
196 views

Solidity: How can a contract B, burn from contract A, generate another contract?

As we know if we want contract A, in the future, creates another contract: contract B, when we're deploying contract A, we also put the code of contract B in the transaction. So we send the following ...
1
vote
1answer
430 views

Are contracts able to send messages to EOA's?

I know that EOA's can send transactions between each other, but also to contracts. However, contracts can only send so-called messages, i.e. data without signature (authentication). I'm confused, ...
1
vote
1answer
111 views

System for paid retrieval of (secret) information possible?

I've been thinking about designing a system, where every student's grades are stored on the blockchain in encrypted form. However, I've read enough posts describing why this is not a good idea: ...
1
vote
1answer
179 views

Store specific data related to users

Scenario - need to store on blockchain specific data related to users. potentially very large number of users data should not be changed in the future, and that's the whole point to make it immutable ...
0
votes
1answer
421 views

Tracking transaction status using ethereum private chain

I am implementing an order management system using ethereum private block chain. Each order is a smart contract. Each order will be acted upon by multiple actors. The status of the order will also be ...
0
votes
1answer
46 views

Is the following scenario doable by a smart contract?

I have 2 persons ( say A or B). They want to have the following agreement. Person ‘A’ specify a deposit (x coins ) for user ‘B’ under a certain condition with a future time lock ‘t’. If user ‘B’ ...
0
votes
1answer
525 views

Getting TypeError: Operator == not compatible with types int_const 1000000000000000000 and address payable

I am trying to use external modifier however I getting error as below code. { require(block.timestamp < start + buyPeriod); require(1 ether == msg.sender);<--- error got here ...
0
votes
1answer
436 views

Transferring tokens to hardcoded addresses

If i have a list of addresses and the exact amount of tokens that I want sent to each address, how can I hardcode a transfer function to transfer the exact amount of tokens to all specific addresses ...
0
votes
1answer
31 views

how does gas get taken from the account?

Let's say we call the function: function nice(uint a) public returns(uint256){ k = 100; z = 100; f = 100; require(a == 5); ...
0
votes
0answers
20 views

ethereum solidity - gas cost wrong

This is bugging me so much time and spent hours and hours on this, I'd really appreciate your help so much.... // this costs 21394 function test2() external { } // this costs 21507 function ...
0
votes
1answer
33 views

Using ethereum to fund distributed cloud computations?

Okay, so assume there's a Web API that offers some kind of service / computation at a given cost. This API itself relies on calling another API that also has a cost. Would it be possible to set up ...
0
votes
1answer
164 views

how do i pass by reference?

I have a couple of questions. First: So, In a function, i created memory array. I want to pass this memory by reference to another function.. function test2() public returns(uint a) { uint[2] ...
0
votes
1answer
50 views

ethereum - call and delegatecall not working

pragma solidity >=0.4.22 <0.7.0; contract D { uint public n; address public sender; function callSetN(address _e, uint256 _n) public { _e.call(abi.encode(bytes4(keccak256("setN(...
0
votes
3answers
1k views

Concurrent calls to a contract - state changes

So user a and user b both call a function (transaction) on a deployed contract with the code as bellow. uint numberA; uint numberB; address playerA; address playerB; function playANumber(uint number)...
0
votes
1answer
224 views

How to avoid using tx.origin when we really need it?

It's been recommended that we should avoid using tx.origin. However, there're some cases it's really needed, like the following case. Assume we have two smart contracts: Sc1 and Sc2, both of which ...
0
votes
1answer
2k views

ERC20 - Approve & TransferFrom not working

The getTokenBalance function seems to retrieve data from the ERC20 contract just fine so I don't think there is an issue with how I'm using the interface. Additionally, I also tested out separating ...
0
votes
2answers
214 views

Smart contract with authorized actions based on addresses

I want to build a service where users can sign up (off-chain) to get credentials which give them the right to perform certain on-chain actions. For example, lets pretend I'm building a service where ...
0
votes
2answers
2k views

Division/Percentages in Solidity (a workaround)

Division/percentages is a required part of many applications but is difficult to implement since fixed and ufixed are not supported yet in Solidity. I've come up with this workaround: pragma ...
0
votes
1answer
36 views

How you can have real-time database modifications if transactions require acceptance by all others

I'm trying to understand the current implementation of smart contracts and transactions and am wondering about real-time behavior. I read that it can take up to 10 minutes for a transaction to become ...
0
votes
2answers
1k views

Increase all values of mapping or array without loop

Would it be possible to increase all the values of a mapping or array (without a loop)? Example: mapping(address => uint) score; uint[] values; function increase_scores() public { // ...
0
votes
1answer
136 views

In ICOs why initial supply/total supply tokens are transferred to owner address rather than storing it in the contract itself?

Here I have taken two of the top 20 ERC20 Token/ICO. 1.BNB(https://etherscan.io/address/0xB8c77482e45F1F44dE1745F52C74426C631bDD52#code) 2.BAT(https://etherscan.io/address/...
0
votes
1answer
182 views

Quorum - Track State Variable Changes in Struct (Data Lineage)

I am unable to get my bytes32 variable state transition within a struct in Quorum. What I did is to I build a dashboard to loop through the blockchain to search for a particular then list out the ...

1 2 3 4
5