Questions tagged [contract-design]

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

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

How to enter a uint256[] function input in java script?

I'm trying to interact with my smart contract using java script. My function uses an uint256[] input. In python the desired input would be input = [1,2] In java script I tried const arrayindex ...
0
votes
1answer
7 views

Recording gas usage at a specific point in execution

I apologize if it has already been asked here, but i'm currently building a limit orders contract and i'm trying to do something like that. function fullfillMaxOrders() public { while(gasConsumed <=...
2
votes
2answers
171 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 ...
0
votes
1answer
10 views

Can I interact with a smart-contract that's a variable inside another smart-contract?

I want to interact with a third party contract. I can interact with (third party) Smart Contract A. Inside Smart Contract A's code is import { contractb } from ".../ContractB.sol"; ...
0
votes
2answers
82 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 ...
0
votes
1answer
12 views

Is it common to add comission to the contract for the secondary market?

I looked at Cryptopunks contract and I don't see any royalty going to Larva Labs. Is it normal to add a comission back to me for my generative art project? I noticed some projects take a set price ...
0
votes
0answers
13 views

Using the return value of a contract function in another function

I have a smart contract A with a public function a1 that can be called by anyone and this public function will return a uint value based on another public function named a2 inside the same contract A. ...
0
votes
1answer
134 views

Can you have an array of mappings? The mappings have an address key and a struct value

Can you have an array of mappings? I want to have mappings with addresses as keys and structs as the value. I want to store these addresses in an array and iterate through them. so far it looks like ...
0
votes
1answer
19 views

How to change the bet of ether into bep-20 token?

The link of Betting Contract:https://github.com/laronlineworld/Voting-Betting-Smart-Contract/blob/main/Voting-Betting-Smart-Contract.sol How to change the bet ether into token(BEP20) function ...
2
votes
1answer
83 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 ...
4
votes
3answers
5k views

Deploying a Contract at Test Time with truffle

I'm having trouble getting my test harness set up in truffle. I have 2 contracts. The first is an Issuing authority and in order for the second to be deployed, the creation address must be ...
0
votes
1answer
50 views

Withdraw Tokens from a contract

I'm looking for a way to withdraw tokens from a contract. Is that possible? I know how to withdraw basic tokens like eth and bnb from a smart contract but I want to withdraw tokens from a contract.
1
vote
2answers
82 views

Storage/Retrieval of mapped structure data

I want to store the structure data in a mapping i.e. if I have a student structure as described below, then I should be able to have a myriad of students and distinguish between them using wallet ...
0
votes
1answer
12 views

Which section should be first? Upstream and downstream sections

Well... I have a problem of starting writing smart contract in with I don't know which part should be written first. For example we have a game. It has a hero and it has some functions like fighting ...
0
votes
1answer
12 views

Is there a smart contract that rewards someone who has held a token for a certain amount of time with additional tokens?

Basically if someone holds a token for a given time "x" amount then they are rewarded extra tokens? Is there a smart contract that can do this or is it even possible? Thank you.
0
votes
2answers
419 views

Is there a way to dynamically create a contract that points to a previous contract?

I would like to implement a tracking system .. where i track events between two parties who deliver an item between them .. then the receiver would deliver it to another person and so on... I would ...
0
votes
1answer
40 views

Dynamically calling any other contract and function from contract

This gives a contract the same ability to interact with other contracts (with its address as msg.sender), as an externally-owned account, right? function call(address _contract, bytes calldata ...
30
votes
2answers
13k views

Deploy contract from contract in Solidity

It's a common pattern to use a hub/factory contract to create multiple instances of a standard contract. It's also common to require a way to enumerate the addresses of the created contracts. Is ...
0
votes
1answer
105 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 ...
1
vote
1answer
23 views

Is it possible to create a vault that will open itself after a countdown (dead man's switch) on blockchain?

I know I can put an encrypted data and a timer in the contract, but what about the key? People can't know the key. It must be only used when the countdown ends, automatically.
0
votes
1answer
25 views

How to return a storage array from a Solidity function?

I wrote a very simple smart-contract where I want to create an external function which returns as an output a storage array which contains the following items [0,2,4,6,8,10,12,14,16,18]: pragma ...
0
votes
1answer
22 views

Can I automatically forward transactions from a given address?

The challenge is to provably promise to transfer a transaction from address X to address Y. Basically, I need to be able to convince Y that if I get the money from X - it's going straight to Y. X is ...
1
vote
1answer
98 views

retrieving tokens from contract

I am using the MyAdvancedToken code from: https://www.ethereum.org/token I transferred tokens from owner account into the contract, to fund any buy(). Now, I want those tokens back. Is there any ...
1
vote
1answer
173 views

Force two users to send the same amount of ether when starting a game

In my smart contract, I want the two participants to send the same amount of ether so they can start a game of rock, paper, scissors. How can I modify the sendEnoughCash() function do that? This is ...
2
votes
1answer
104 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 ...
1
vote
1answer
74 views

Determine number of holders in solidity

I saw a lot of questions over the internet on how to determine the number of token holders in solidity and everybody says that its impossible to be determined without interacting with a solution that ...
0
votes
1answer
21 views

DeclarationError: Identifier already declared

I'm getting the below compile error message: DeclarationError: Identifier already declared. --> contracts/coffeeBase/SupplyChain.sol:9:1: | 9 | import "../coffeeAccessControl/ConsumerRole.sol&...
0
votes
1answer
41 views

What is the pros/cons of inheritence vs new Contract

I noticed from this answer that there's two ways of separating Contract code with state variables: Inheritance (class Contract is XY {}) or Reference (otherClass = new OtherClass()) I'm wondering what ...
1
vote
0answers
17 views

Contracts Handling Incoming Transactions Without Receive/Fallback Functions

If a contract doesn't have a receive function nor a fallback function defined and the contract receives a transaction as a miner reward or a selfdestruct call, what does the contract do? Does the ...
2
votes
1answer
273 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 ...
0
votes
1answer
18 views

etherscan verification for newly deployed contracts

from my UI, I call a contract function through ethers.js that deploys a new contract. It's like user comes to the UI, clicks a button that calls a contract function and then, that contract function ...
0
votes
2answers
171 views

Election smart contracts

I'm having trouble implementing a time out factor in my election. Lets say when the contract is deployed the timer kicks off, after the timer runs out the election ends and it announces the results of ...
0
votes
1answer
22 views

What is the difference between contract type and address?

I have seen here that: Contract TokenCreator { function createToken(bytes32 name) public returns (OwnedToken tokenAddress) { // Create a new `Token` contract and return ...
2
votes
1answer
127 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 ...
74
votes
5answers
29k views

Difference between CALL, CALLCODE and DELEGATECALL

CALL and CALLCODE take the same number of operands (in the execution stack). For the exception flag being pushed on top of the stack: 0 means exception, 1 means successful execution. CALL is easy to ...
3
votes
1answer
172 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 ...
0
votes
1answer
18 views

Unsandwiching multiple erc20 transfers

How can I un-sandwich multiple transfers from a batch transfer? Basically, I want to execute i.e. 30 transfers and have them show up as individual transfers on Etherscan rather than a sandwich tx that ...
0
votes
2answers
39 views

Does this mean someone could take ownership of this contract since it is public?

I'm new to programming languages and trying to dive into solidity smart contracts, but does this mean that this contract could be taken over by anyone calling it due to it being public? Sorry if this ...
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
3answers
118 views

Alphanumeric ranking of adresses

How is it possible in an ethereum contract to sort the public adresses of senders of eth in the contract in the alphanumeric order ?
0
votes
1answer
569 views

Solidity: Wrapping an ERC20 token inside of a new token

Is it possible to wrap and track a ERC20 token amount in another token? Would I need to use ERC-721 to do this? Let's say I send my ERC20 token to a specific smart contract which will wrap it in a new ...
0
votes
0answers
17 views

Effective way of doing data search in Ethereum Smartcontracts

Actually I am writing smartcontracts in such a way that I have upgradeable and non-upgradeable contracts. Lets say I have contractA_upgradeable.sol and contractA_nonupgradeable.sol. ...
0
votes
0answers
19 views

Does it cost more gas to call a function more than once in another function?

Does it cost more gas to call a function more than once in another function? For example: function getValue() public returns(uint){ return 5; } function getOtherValue() public returns(uint){ ...
0
votes
1answer
100 views

Is it possible to modify privateFor addreses in a private Smart Contract (Quorum)?

I know how a private smart contract works providing a list of accepted addreses to privateFor property, but what if I want to disable (or enable) any address visibility? Should I deploy a new Smart ...
1
vote
1answer
97 views

Can you act on an integer overflow in Solidity 0.8?

With integer underflow/overflow throwing a panic error in Solidity >=0.8, would it be possible to write a conditional in an instance of that happening? Example: I want to add a constant type(...
0
votes
1answer
131 views

Browsing a mapping variable

This is my contract where I am building a list of members who will use a addVote function. The allMembersVoted function always seems to return false even though the Remix debugger shows that, the ...
0
votes
1answer
112 views

Token Distribution Calculation

If I have a Contract A receiving 50000 'XXX' tokens from a contract B, those tokens are supposed to be distributed across 5 whitelisted users who has pooled 'xx' Ether into contract A, how can I make ...
2
votes
1answer
271 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 ...
1
vote
1answer
98 views

Would this make sense as a smart contract application? Trying to understand features and limitations

I'm starting to read up on Ethereum and smart contracts and some questions are popping up in my mind. I can understand that smart contracts can be used, for example, to make a bet for/against the ...
5
votes
4answers
5k views

What are function modifiers?

I am learning solidity. I came across the concept of function modifiers. I am unable to understand it.

1
2 3 4 5
38