Questions tagged [contract-design]

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

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

DeclarationError:identifier already declared Masterchef.sol

I'm getting the error, what's wrong? // SPDX-License-Identifier: MIT pragma solidity 0.6.12; import "./SafeMath.sol"; import "./IBEP20.sol"; import "./SafeBEP20.sol"; ...
0
votes
1answer
23 views

Access a public mapping of mapping of a contract from another contract already published

contract Published { struct Test { uint testData_1; uint testData_2; } // address => tokenId => struct mapping(address => mapping(uint256 => Test)) ...
0
votes
0answers
4 views

Why is it more expensive to declare storage variables in a proxy?

I want to deploy many contracts with the same functionality, so I decided to use delegatecalls. I have my contract ActualContract that contains all the functionality and a contract ProxyContract that ...
0
votes
0answers
13 views

Smart contract that recognizes Tweets made by each Twitter user [duplicate]

Is there a way for a Solidity smart contract to interface with Twitter accounts or Twitter API to recognize the number of "relevantly tagged" tweets that account made? For example, an ERC-20 ...
0
votes
0answers
7 views

Best way to use timestamp to automatic activate function or allow function execution

What is the best way to use the timestamp to automatically activate function or allow function execution? For example, I want to allow a user to buy a token only if is in the timestamp interval that I ...
0
votes
1answer
20 views

Initialize state variables in the contract constructor or directly in the declaration?

Is there any difference when initializing variables in the contract constructor or directly in the declaration? What is the best practice? contract A { uint public storage = 10000; constructor(){...
0
votes
0answers
17 views

how to have base contracts have same variables

I have 2 base contracts. contract Base1 { function nice1() public { } } contract Base2 { function nice2() public { } } contract Derived is Base1, Base2 { function ...
0
votes
0answers
12 views

Could a free field in a EIP712 typed structure be manipulated for some reason?

I'm using the OpenZeppelin's EIP712 implementation for a project where users can make an offchain signature of a certain structure to give a contract the permission to do something with their token (...
0
votes
1answer
19 views

Need help implementing Burn Logic in an ERC-20 token

I am learning solidity and have decided to program my own ERC-20 token. I have inherited the ERC-20 Open Zeppelin standard, but would like to add some functionality that calculates 5% of every ...
1
vote
1answer
23 views

Code for staking Ethereum

Ethereum enabled staking for anyone with a minimum of 32 ETH. Where can I see the code of their staking protocol? Is it a .sol file? Is it a contract address whose code is viewable on Etherscan? ...
0
votes
1answer
17 views

The longer a smart contract interaction's code is, the higher the gas?

It seems that different contract interactions cost different amounts of gas. For example, minting an NFT costs much more gas than the action of transferring some ether to another wallet. Are these gas ...
0
votes
0answers
20 views

Will adding parameters to burn event mean contract is no longer ERC20 compliant?

I am assigned to a task on a ERC20 contract, where I have been requested to add some additional data to the existing burn event. Other than this extra data on said event, the contract is just a normal ...
0
votes
0answers
24 views

Ropsten testnet vs ETH mainnet erc20 contract

I was trying to c/p a contract and change tax wallet address for buy and sell transactions, but the function is not working properly on Ropsten as it works on mainnet. Tax is charged, but not send to ...
0
votes
0answers
14 views

Design question on a 3-parties Smart Contract system with ERC-721, Escrow (and Factory Pattern)

I need some advice from your side. I'm currently struggling to write 3 Smart Contracts interacting with each other. Lastly, I just read about the Factory/Singleton Pattern that is often used to manage ...
0
votes
0answers
41 views

Problem with "Verify & Publish Contract Source Code" on BscScan

I wanted to "Verify & Publish Contract Source Code" on BscScan, but I get this message: ParserError: Multiple SPDX license identifiers found in source file. Use "AND" or "...
1
vote
1answer
61 views

NFT minting in random way from csv file

I am a new in solidity so have a questions regarding minting NFT from csv. There is a .csv file with 1000 rows in each row - 5 attributes. These rows should be taken randomly for lazy minting 1000 NFT ...
0
votes
1answer
39 views

Transaction reverted by the EVM and I cannot see the reason

I am new to blockchain technology and ethereum contracts development and I cannot track down the bug I have in my first contract code. This is an ERC-721 (NFT) contract type. NFT is a reward for ...
0
votes
0answers
14 views

Certification programs for Solidity and smart contract coding

Writing smart contracts is not taught in university, so what are some authentic training courses dedicated to Solidity that smart contract professionals most often display on their CV, and can obtain ...
0
votes
1answer
19 views

Is there a difference between using ContractName.func and func when calling func in a given contract?

I have started to learn solidity with _buildspaces tutorials. In these tuto we have for example: contract MyContract { function foo() internal view returns (uint memory) { return 0; } ...
0
votes
0answers
12 views

Does the phenomenon of ‘bad money drives out good’ (Gresham's law) apply to Ether?

In the case of coinage, it’s the tendency toward the substitution of all high value coinage with less valuable coinage. In our case as the quantitative value cannot be changed in this manner, can ...
0
votes
1answer
20 views

Where is the royality amount defined?

i'm currently diving into the whole topic NFT, blockchain and smart contracs. I also played around with some smart contracts on my own ganache blockchain. Everything is more or less clear to me, but ...
0
votes
0answers
25 views

Q: How can I fully handle wallets and transactions without any user confirmation?

I am attempting to create a messenger DApp for a small group of users. My goal is to avoid things like transaction signage popups and wallet funds by paying and signing everything for all users in the ...
0
votes
0answers
24 views

Is there any proposed way for a person to prove identity to claim entitlement as beneficiary under a smart contract [duplicate]

Suppose I am a very rich individual and want to leave a lot of money in trust to my descendants, but I don't necessarily know who they all are, or maybe they aren't even alive yet. I would like to ...
3
votes
1answer
38 views

in OpenZeppelin's ERC721 why are tokenapprovals more restrictive that operatorApprovals

In OpenZeppelin's ERC721 contract what was the design decision behind making _tokenapprovals a mapping, but _operatorApprovals a multidimensional mapping? Why restrict the ability to approve transfer ...
0
votes
1answer
72 views

Solidity MINT ERC20

I will try to be brief in my doubt, below I am putting a model of a Smart Contract referring to a currency that I am creating for my game. // SPDX-License-Identifier: MIT pragma solidity >=0.4.22 &...
0
votes
0answers
21 views

How can I monetize my online app with ERC-20 tokens?

I guess I have a very common use case, but I don't know how to implement it right: Consider, I have a simple online app that users can use to do something (e.g. create a badge by users data, convert ...
0
votes
0answers
20 views

how does ERC223 ensure there's no need for approve/transferFrom

We all know what approve/transferFrom work in ERC220. Now, I am looking at ERC223 which also has the transfer function. After reading its docs, It's said that for ERC223, there's no need for approve/...
0
votes
0answers
24 views

Function fails randomly

In my contract I have a function that allocates funds to a bunch of shareholders according to their respective shares. Not sure why it reverts. The strange thing is it used to work some 3 months ago ...
0
votes
1answer
78 views

Event logs vs Storage in Solidity

In my ethereum smart contract, I have a function that registers a user (by adding a user object to a mapping). I am also triggering an event after successful registration to notify the user about the ...
1
vote
0answers
15 views

Bep20 - I sent the token to the Token Address [duplicate]

I accidentally sent the token to the contract itself. This mistake is worth more than $300,000 as of now. I was wondering if ANYONE could look over the code and help me resolve this issue. Is there ...
1
vote
1answer
30 views

I need help understanding differences between Inheritance/Import vs Separate Contract vs Libraries/Interface

I understand that for good organization and to preserve flexibility, it is good practice to separate code by functionality. For example: separate your datastorage from app logic. To do this, AFAIK, we ...
0
votes
0answers
37 views

Import existing code in Solidity, does it affect contract gas price?

I understand that import your own code in smart contract effect it's gas price (you can find more here: Import in Solidity.. Does it affect the Gas?) But what about already existing code? Let's say I'...
1
vote
0answers
28 views

Best practices for a large airdrop

I read an article on hacknoon where a company said they implemented an airdrop to 40000 customers by using a function that takes an address[] recipients parameter. While they did repeatedly call the ...
0
votes
0answers
33 views

Bep20 parse error reflection function

Hi hi got this parse error in my contract could anybody help me to solve it? thanks a lot :) don't mind about token name and token symbol :) pragma solidity 0.5.16; interface IBEP20 { function ...
0
votes
0answers
112 views

Transferring a Token without approval

I've been following the following article about avoiding gas fees when selling a token on the Polygon network from OpenSea. https://docs.opensea.io/docs/polygon-basic-integration There it states that ...
0
votes
0answers
8 views

Staking an ERC20 with another value associated

I'm working on something and I already have an ERC20 pattern token with staking capabilities. I need to make a contract that activates this staking function and associates the staked value from that ...
0
votes
1answer
160 views

Number of NFT tokens to mint

I see that many smart contracts for minting NFT tokens use a function that accepts the number of tokens to be minted, here are examples: function adopt(uint256 num) public payable function mintAlien(...
1
vote
1answer
30 views

"Super" keyword with same function in multiple inheritance contracts?

I'm having some doubts when extending the same contract function in different classes, with super keyword. Would function _preValidate (in Contract B) check both conditions of contracts A1 & A2, ...
0
votes
0answers
29 views

Solidity re-entrancy attacks and how to guard against them

I'm trying to understand re-entrancy attacks. Is tip1() below at risk of a re-entrancy attack (if the fallback function of the miner's contract invokes tip1() itself)? And if so, is tip2() safe? ...
0
votes
1answer
27 views

Can you use smart contract 'instances' rather than deploying each new contract?

My apologies in advance for this noob question, I think a scenario might be the best way to ask: I have a simple escrow smart contract that facilitates the buying of products. For simplicity sake, the ...
1
vote
0answers
22 views

Is using blockhash a good source of randomness on PoS blockchains with a lot of blocks mined in a short period of time?

I am trying to make a casino-like game using a smart contract and employing only on-chain data. I understand that on a blockchain like Ethereum a malicious miner can cheat the system by withholding ...
0
votes
1answer
78 views

Is it possible to upgrade an NFT instead of having to burn the previous and creating a new one?

I wanted to know if this was possible. For example, if I own 1 NFT of Charmander and I then "mint" an evolve, is there a way to turn the first Charmander into Charmeleon without creating a ...
3
votes
2answers
142 views

Why do we grant access to our funds instead of just sending them to the smart contract?

In DeFi I have seen that users are prompted to give access to their funds. Why not just send those funds to the smart contract instead? What is the advantage of this design?
0
votes
1answer
25 views

Storing struct with mapping inside of mapping

I have the following structures defined in my smart contract: mapping(bytes4 => Question) private questions; struct Question { bytes8[] answers; mapping(bytes32 => bool) answerers; } ...
0
votes
0answers
19 views

Let users add data to smart contract anonymously: Possible?

To learn more about smart contracts, I thought I could start by building a super simple dApp, which only does two things: Allow users (addresses) to share some random info to the contract (In my case ...
0
votes
0answers
17 views

Best practices for functions with highly variable gas cost

I'm developing a Dapp with a function (let's just call functionA) that has potentially significantly different gas cost between invocations. This is due to the need for costly extra computation when ...
0
votes
0answers
25 views

Can an external source be used in place of a proxy contract?

The recommended way to create updatable contracts is to create a proxy contract which then calls an origial contract. I haven’t worked with proxy contracts yet, but I’ve seen the code and it appeared ...
0
votes
1answer
16 views

Why do we need to use private variable getters inside the same contract?

I recently read a smart contract from Openzepplin with the following code in it uint256 private certainAmount; function getCertainAmount() public returns (uint256){ return ...
1
vote
0answers
40 views

Does a proxy contract need to declare state variables?

There is no variable declaration in the proxy contract. Does the returned data from the delegate call auto-generate the variables for the proxy contract? contract Logic { uint256 varA; ...
1
vote
0answers
55 views

Typical flow for generating large set of unique ERC-721 metadata and setting tokenURI

First of all, I have searched around in previous posts and haven't found an answer to this so apologies in advance if this is a duplicate. I am minting a collection of NFTs via ERC-721 and have the ...

1
2 3 4 5
40