Questions tagged [contract-design]
for high-level questions about the choices made during contract construction
2,015
questions
0
votes
1
answer
17
views
I need to write a contract for state synced ETH <> Polygon staking, any advice on how to do this would be very appreciated
I need to write a contract for state synced ETH <> Polygon(L2) staking. NFTs will need to be staked in return for tokens on Polygon. Where do I even start with this sort of thing, is their ...
0
votes
1
answer
10
views
How is msg.value sent?
I'm wondering how exactly "msg.value" works, like here in this example taken from https://solidity-by-example.org/hacks/self-destruct
How can the deposit function require msg.value to eqaul ...
0
votes
0
answers
18
views
setApprovalForAll(..) with OpenSea
I'm still bothering with OpenSea...
I'm creating some tokens in OpenSea in Rinkeby, and I'm transferring them via web3 (ethers) through some scripts that I built myself.
Question, I have had to ...
0
votes
1
answer
20
views
Can a smart contract have multiple addresses?
Can a smart contract have multiple addresses? And I am not asking whether a smart contract can have other smart-contracts. What I am asking is, theoretically can a smart contract have multiple ...
1
vote
1
answer
26
views
ERC1155 Deficiencies
I'm using a direct implementation of these in a different language and considering the deficiencies of 1155. There is no shortage of articles comparing 721 vs 1155, but all of them go on to say 1155 ...
0
votes
1
answer
34
views
Generating Randomized Start Index for TokenIds in a NFT Contract
I've recently started exploring and learning Solidity and have been looking at contracts of some of the famous NFT projects.
One common pattern that I've found is that most of them set a ...
0
votes
0
answers
5
views
Gas usage for 1155 vs 721a
A client is looking to optimize gas usage for an nft contract. Which uses less gas for minting/transfers (deployment isn’t really a concern but input on it is definitely welcome)? The collection in ...
0
votes
0
answers
17
views
How to resolve "TypeError: Type address is not implicitly convertible to expected type address payable"? (Solidity 0.8.13) [duplicate]
I am trying to execute the below smart contract for hotel booking however, there is a type error stating "address is not implicitly convertible to expected type address payable". Please help ...
0
votes
1
answer
12
views
Can you create and destroy a contract in a single transaction?
Is it possible to create and destroy a contract in a single transaction? Specifically could I:
deploy to a known address using CREATE2
call a function on that contract
destroy the contract and ...
0
votes
0
answers
21
views
why does EOA > contract cost more than contract > contract
Simple question but I'm having a hard time finding a clear answer online.
I'm told contract -> contract interactions are cheaper (in terms of gas) compared to EOA -> contract interactions. What ...
0
votes
1
answer
15
views
Two requirement were set for a function however, the reason of unsuccessful transaction displays only for one reason
I have set two requirements for withdrawing Money;
(a) the beneficiary has to be the initiator of Smartcontract (SM) and
(b) the contract will pause if condition (a) is not met.
However, the reason of ...
0
votes
0
answers
12
views
Check Wallet For NFT From Collection Args
I'm trying to implement a whitelist based on NFT ownership from a collection. The whitelist also implements timeout between calls, so the current model is mapping(address=>date) whitelist; where ...
0
votes
1
answer
19
views
NFT Sent to Smart Contract
https://etherscan.io/address/0x23581767a106ae21c074b2276D25e5C3e136a68b#code
Had a pretty big oopsy. I know. No one is kicking myself more than me.
That being said, was curious if anyone saw a ...
0
votes
1
answer
23
views
Error: "Struct containing a (nested) mapping cannot be constructed"
While writing a contract that uses structs, I'm getting an error by the linter "Struct containing a (nested) mapping cannot be constructed".
According to this, the problem with structs is ...
1
vote
1
answer
24
views
How would you structure this smart contract: ownership percentages, ERC777, UI flow?
I'm trying to get familiar with the patterns in designing Solidity smart contracts.
For example, say I'm trying to model a Mall with multiple Restaurants in it. Each restaurant can have multiple ...
0
votes
0
answers
19
views
freeze and unfreeze
We want to create our project token and ico it on the platform we designed for this purpose.But we want every token buyer not to be able to transfer for up to a year from the time they receive the ...
0
votes
0
answers
14
views
Hello I want to be done
there is a question when adding gas fee to my cryptocurrency, I want to distribute coin gas fee to holders of nft (my project), how is it possible in solidity, can you help me, thank you
My naime jeff
0
votes
0
answers
26
views
Handling encryption of data in smart contract based app (specific scenario)
Small heads up, I'm a complete beginner, so many concepts are still unclear for me. Please correct me at any point if I'm talking nonsense.
My question is how should data stored in a smart contract be ...
0
votes
0
answers
17
views
implementing a scaling tax rate in erc20 tokens
I am looking for a way to scale the amount taxed depending on the amount, of tokens bought in an erc20 contract. For instance, it would cost less tax to buy 10 than it would cost to buy 5 tokens. Not ...
0
votes
0
answers
35
views
Trying to build a Factory of Upgradeable contracts and need a feedback
I'm trying to create an upgradeable factory contract that can create proxies of ERC20 tokens.
I have the Factory contract that is:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "...
0
votes
1
answer
24
views
How to store contract state on multiple blocks?
Eth blocks have a clear block size and gas limit (of 30,000,000).
Some contract states must require more memory than the defined block size, right?
Now my question: can the contract state be saved on ...
0
votes
1
answer
24
views
Get data from mapping whose values are struct and keys as address (msg.sender)
Hey so this is my solidity code, when I am running the getter functions, I am not seeing any output. And as for a fact I don't even know whether the setter functions are even working or not. Please ...
0
votes
0
answers
14
views
Delete struct from array of structs
I've found a great answer to do things with an array of structs here but I am a bit confused about one particular example which is below:
contract mappingWithStruct {
struct EntityStruct {
uint ...
0
votes
0
answers
11
views
Tokens and ICO relationship
1.) I am little confused with Total Supply in Token as I used ERC20 interface.
So how is the totalSupply is going to be affected after each transfer() ?
2.) Is it necessary to have ICO for token or ...
0
votes
2
answers
38
views
Contract "NFTMarket" should be marked as abstract (when implementing IERC721Receiver interface along with ReentrancyGuard)
I've read other similar questions but none of them applies to my smart contract current setup.
Currently I have a working smart contract that only implements ReentrancyGuard.
Here below an snippet of ...
0
votes
0
answers
12
views
How much does it cost to sell a smart contract made in solidity, how do I get this quote?
I would like to ask you something, let's say you were going to sell this smart contract so I developed in solidity a software that simulates an electronic voting machine, would someone know how to ...
0
votes
0
answers
19
views
What are the pros and cons of storing contracts vs their addresses?
What are the pros and cons of storing a contract address in state and loading the contract using that address as required vs storing the contract/interface directly in state as shown below? ...
2
votes
1
answer
189
views
Correct way to create a ERC1155 collection
I am working on creating a contract that implements ERC1155 tokens. I want to be able to init a collection with different tiers.
So let's say 3 tiers, tier1 will have 15 supply, tier2 50 supply and ...
0
votes
0
answers
10
views
Is there any network (or some way) that can store millions users' info?
I'm working on a project that need to store millions of users' data, but as far as i know, it would be incredibly expansive. I've read some blogs, and they suggest to using IPFS/Swarm/Filecoin. ...
1
vote
3
answers
113
views
Make my value in smart contract only accessible by the owner?
Hey everyone I am trying to implement the game Chinese Whisper as a smart contract.
It works as intended, but there are two issues I have.
I will explain the contract idea quickly:
So WalletA can send ...
0
votes
1
answer
226
views
EnumerableSet vs Access Control in Openzeppelin
Openzeppelin offers RBAC whereby an address may be granted a specific set of responsibilities.
I would like to know which might be considered a better practice - using Access Control Or using an ...
0
votes
0
answers
66
views
UUPS proxy with the Brownie framework
I am trying to implement a UUPS proxy using the OpenZeppelin UUPSUpgradeable abstract contract. I actually succeeded to do so but I think that there may be a better way than the one I found.
In other ...
0
votes
1
answer
28
views
What does passing msg.sender to an interface do?
I was doing Ethernaut's Elevator problem when I noticed the code below:
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;
interface Building {
function isLastFloor(uint) external returns (...
0
votes
1
answer
51
views
Getting "Insufficient fund" error from calling other contract
I created two contracts which are Balance and TempDeposit. In the Balance contract, I wrote Mint function in order to mint certain number of token stored in the contract. Total token minted will be ...
0
votes
0
answers
41
views
Ways to validate that an EOA has authority over a smart contract?
How to validate that an EOA account has authority over a smart contract account, within solidity code?
If msg.sender is a smart contract, is there a way in solidity to find out who deployed that smart ...
0
votes
1
answer
77
views
Permissioned Contract Interactions
I want users to mint NFTs on my ERC1155 contract
but I don't want to pay the gas fees
but I only want them to mint if I allow them
so I was thinking maybe I would sign a transactinon on the backend, ...
2
votes
1
answer
51
views
Can calldata be used in every function visibility?
When I look at it in general, everywhere it says calldata is used only with external visibility, but I can also use it with public while writing a contract? Because when I use public, there is no ...
0
votes
1
answer
57
views
How to handle multiple copies on sale in an erc1155 marketplace contract
I am unsure how to create a marketplace contract for erc1155 nfts due to there being multiple copies on sale at the same time. What is the best way to implement this?
Code examples would be great....
0
votes
0
answers
11
views
How to add multiple wallets for reflections (Developer, marketing)
Im and engineer learning new ways in solidity.
I would like to know how is it possible to create a coin that deducts tax and the tax automatically distributes to 2 different wallet (Developer, ...
0
votes
1
answer
21
views
ParserError: Expected '{' but got '}' I keep getting this error when I try to compile my code
I get this error every time that I try to compile my code. These curly brackets run from the beginning of my contract to the very end. I'm new to smart contracts, and this does not make much sense to ...
0
votes
0
answers
15
views
delegatecall, but with modifying the Caller contract state?
Example: EOA -> Caller Contract -> Target Contract
As far as I can tell, delegatecall differs from normal calls in two very important ways:
Call context is preserved, msg.value and msg.sender ...
0
votes
0
answers
27
views
Contract fee - implementation
I am working on a new token (BSC) and I would like to include a sell tax of 60% which will decrease overtime.
My questions are as follows: 1- Pancakeswap max slippage is 50% and would like to know if ...
0
votes
1
answer
231
views
How to fetch tokenURI from Polygon smart contract?
I am trying to analyse different tokens in terms of the metadata they link to. I found a Polygon-based token project: https://opensea.io/assets/matic/0x50c2eae4903261b386c27c1733588e867f1a33db/10200
I ...
0
votes
1
answer
12
views
How do require statements affect previously computed logic
If I have a function that changes the state of the contract, and further down in the same function, there is a require statement. What happens to the contract state if something fails to pass the ...
0
votes
1
answer
29
views
Could somebody breakdown what this contract is doing? Polyscan contract has dropped Matic to a whole load of wallets
This contract (https://polygonscan.com/address/0x1087e19b00d6916e4de1cf84ad01874bcada8156#internaltx) seemingly dropped 0.25 MATIC into a whole load of wallets over the space of an hour a few days ago....
0
votes
1
answer
34
views
Can I take a mapping from one contract, and access it with an interface from anther contract?
Lets say I have a mapping in contract A, which is already deployed.. Can I use an interface in contract B to access the mapping (and the values it links)? If not, is there any way to do this?
1
vote
1
answer
141
views
Provable way to whitelist a contract before it is deployed?
I would like to prove that a contract, that is going to be deployed, matches specific code and potentially with a specific state too.
For example, Bob say's he is going to deploy a contract that looks ...
0
votes
0
answers
28
views
Is there a site to see which sites or contracts have full access to my ETH address?
I have an old ETH address that I used to use for everything. How do I know which sites or contracts have FULL access to my address? I know metamask has an option to see which sites are connected, but ...
1
vote
1
answer
197
views
How do I obtain the balance of tokens in a BSC smart contract? [duplicate]
Let's say there is a BEP-20 staking pool contract on the BSC blockchain, and let's say (for extreme simplicity for this example) the address of that contract is "1234".
Upon reviewing the ...
0
votes
0
answers
6
views
Design pattern for cross contract interaction
I am currently working on cross contract function call and I have some design pattern issues related to the cross-contract functions.
First of all, let's assume contract A will call contract B's ...