Questions tagged [contract-design]

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

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

GoFundMe Contract: Minting "Thanks" over time vs all at once & "Thanks" token value

I was assigned to write a smart contract for class (to be deployed on a test-net), which, upon receiving ETH, returns to the sender some amount of tokens with symbol "Thanks". I want this ...
Alex Byard's user avatar
0 votes
1 answer
22 views

Bought a scam token, trying to understand what part of the code should I check next time to prevent that

Contract code - https://etherscan.io/token/0x67bcd18a484a88f073097a18b0462eb7c44d3178#code Ownership renounce at 08:17 UTC https://etherscan.io/tx/...
Dan's user avatar
  • 1
0 votes
0 answers
11 views

How can I mimic legacy bank in my project?

I want to build a project where legacy bank interacts with blockchain networks (over CCIP). Please suggest me how can I mimic a legacy bank - as a separate project or any different idea is appreciated....
Inderdeep01's user avatar
0 votes
1 answer
35 views

How do I add my address to a deployed contract public address using a security exploit? (coding challenge)

I'm working on a coding challenge for smart contract security exploits. I need to add my address to public address (browerr) in the contract. Do I need to create another contract that inherits the ...
johnTg's user avatar
  • 1
3 votes
2 answers
51 views

Are storage variables tightly packed like struct fields?

Tight variable packing is a known coding pattern in Solidity for saving gas by placing struct fields that are lower than 256 bits closer to one another. Does this logic apply to storage variables? ...
Paul Razvan Berg's user avatar
0 votes
1 answer
26 views

How do you use the Diamond Pattern for escrow upgrades?

I am creating a contract with the diamond pattern so I can evolve and add new features to my contract. Contract facets: Contract A: an ERC721 that takes care of minting its own NFTs Contract B: ...
Piyush Chittara's user avatar
0 votes
1 answer
18 views

Can you refer to a contract inside itself?

Sorry this is a very minor question but the following is part of a contract called LibOrders.sol. The function below calls LibOrders.cancelOrder....normally I think you would just put "...
auditor_chick's user avatar
1 vote
1 answer
45 views

Why do some developers make their base contract inherit its Interface?

Some protocols and developers inherit the contract's Interface inside of the base contract and then have the interface contain the actual NatSpec, is this simply for human readability/code ...
Rohan Nero's user avatar
  • 1,408
0 votes
1 answer
135 views

How much does it cost to clog the Ethereum Network exactly?

Currently the largest gas guzzler to clog the Ethereum network is the Mint contract below. Supposedly there are users purposely causing high gas prices using this function. Why would anyone do this ...
Patoshi パトシ's user avatar
0 votes
0 answers
22 views

Function Visibility specifiers during inheritance

when am overriding a function in solidity must my child function have the same visibility as the parent function? can the parent function be public and the child function be internal
Emmanuel Anah's user avatar
0 votes
0 answers
20 views

Token Rewards Calculation and Distribution

I'm doing a script to calculate rewards for a handful of addresses (from sensors). The script runs weekly where it takes a bunch of addresses from our DB, cleans the data and calculates the associated ...
gritty's user avatar
  • 1
1 vote
2 answers
61 views

Malicious smart contract that transfers tokens forth and back

Sorry if my question was already discussed. Is it possible to implement such a smart contract or contracts that in result can transfer eth or ERC20 tokens forth from ANY to B account and back from B ...
Oleg's user avatar
  • 11
0 votes
1 answer
25 views

Can an individual NFT that's not been minted yet have a whitelist?

As it's not been minted yet, it doesn't exist, right? However, what if I had an idea to create a future collection of 333 NFT. And I wanted to allow certain users to mint certain NFTs. Meaning, future ...
DankenN's user avatar
  • 37
0 votes
0 answers
86 views

How to re-mint NFTs to the existing holders?

Suppose, I've created an NFT collection of V1, of ERC751 or ERC1155. After some time, I've discovered that I want to fix a bug or improve it in some way, and this will become V2. I'll then go ahead ...
DankenN's user avatar
  • 37
0 votes
1 answer
160 views

Not able to sell token, where is the tricky code in it

I bought a small amount of this token, but later on doing some more research I found old projects from the creator scamming people: 0x746a2890c506E11597D0b5d805f7d4d6E980667D im not able to sell that ...
Marcel Dz's user avatar
  • 103
0 votes
1 answer
232 views

How to find owner of contract deployer on etherscan website

https://etherscan.io/address/0x6cfa7561bbf940ab4b5c0507d4c9e45c68552b1b On the Etherscan website, where or how do i navigate to the deployer wallet of this contract? Apparently if i look closely at ...
Jim41Mavs's user avatar
  • 103
2 votes
1 answer
75 views

Do immutable variables influence the contract bytecode?

Suppose you have a contract like this: pragma solidity >=0.8.19; contract Bar { uint256 public immutable value; constructor(uint256 value_) { value = value_; } } Will Bar ...
Paul Razvan Berg's user avatar
0 votes
0 answers
58 views

Does gas optimization only apply to leading zeros in contract addresses?

I couldn't find any solid information on this. From assembly perspective clearly PUSH2 0xC0FE for a two byte address 0xC0FE requires less memory than a full PUSH20, but I could swear I also read any ...
Zommuter's user avatar
  • 113
0 votes
1 answer
18 views

How to call a read function within "contract B1" when the function is defined in a higher contract that imports "contract B1" as an extension?

I want to use the totalSupply function within an extension contract, but the function is not declared within the contract and is added in from a different contract extension. Both extensions are ...
Nunber1's user avatar
0 votes
0 answers
28 views

Changing the datatype of one property in a struct goes over the contract size limit?

Given this struct struct Marker { string Key; string Category; bool Include; } Our contract compiles within the size limit. But changing it to struct Marker { bytes4 Key; bytes12 ...
ThomasS's user avatar
  • 11
1 vote
1 answer
1k views

bought a token that is unsellable, but I do not spot the code in the contrat that is responsible

I bought this token, had a good app for trading and a well written medium which didn't seem scammish at all. the token even managed to pass on the normal basic tools for honeypot detection and ...
user119739's user avatar
2 votes
1 answer
58 views

Is there any way to selectively include logic in a contract during its construction?

We have a contract that adheres to the ERC-3156 standard, which provides flash loan functionality. We intend to deploy this contract multiple times, and in certain cases, flash loan capabilities are ...
Paul Razvan Berg's user avatar
2 votes
2 answers
269 views

restrict the NFTs of my contract (ERC721) to be traded on marketplaces?

Are there tricks in solidity to prevent the NFTs minted by an ERC721 contract to be (a) not recognizable and (b) not being transferable by marketplaces like OpenSea, SuperRare. I see those possible ...
Majd TL's user avatar
  • 3,167
2 votes
2 answers
203 views

Why's it all being displayed as Big Number if I am using ethers.utils.parseEther? Is this normally how it displays in console?

In my hardhat test file I am converting ERC20 tokens transactions/balances with ethers.utils.parseEther like... const ONE_ETHER = ethers.utils.parseEther("1"); So if everything is being ...
Blockpain's user avatar
  • 143
1 vote
1 answer
141 views

Troubling shooting hardhat test failure - ERC20 approve & transferFrom issues

One of my hardhat tests is failing and I am hoping someone assist with. I have 2 smart contracts posted here and the test file I am running. My question is at the bottom. It's a bit lengthy to look ...
Blockpain's user avatar
  • 143
1 vote
1 answer
26 views

Is this problem a front-running or race-condition or something else?

What is the correct name of this problem in audit terms? If I have a contract that sells NFTs. The address with the most NTFs has a very high chance to win a prize. The problem is that 1 address can ...
Majd TL's user avatar
  • 3,167
0 votes
1 answer
45 views

ERC1155 and ERC1155UriStorage Question

For anyone who has worked with Open Zepp's ERC1155 and ERC155UriStorage. Both of them have a _setURI function and a uri function (returns the token uri). 2 questions when using both of these ...
Blockpain's user avatar
  • 143
0 votes
0 answers
8 views

Blockchain auditlog

I was thinking about implementing such a project, but do you guys know any other protocol that is doing this? My idea is simple to make a protocol that stores important data (like trades, deals, etc) ...
petar dragnev's user avatar
0 votes
0 answers
29 views

How to design a contract which has independent vesting period for each stake so that it won't run of out gas?

I have a game contract which users can send soldiers. The action of sending soldiers is pretty much identical to staking, and so I'm going to just call it staking for familiarity's sake. Each stake ...
xenon's user avatar
  • 447
1 vote
0 answers
39 views

Creating two separate funds in a single smart contract

I am attempting to create a smart contract with two separate funds/ vaults. So far, I have approached it by creating two separate payable functions, arrays, and mappings with separate permissions for ...
Ryan Glenn's user avatar
0 votes
0 answers
35 views

is this private Etherem based blockchain design spec possible for implementation?

I'm new to Ethereum / blockchain, so if some of the questions seem naive or stupid I apologize in advance. The motivation is, I need a blockchain that can dynamically change its token supply based on ...
user116260's user avatar
1 vote
1 answer
16 views

My payout function to lottery winners is failing. I'm storing the winners in an array and attempting to payout but getting reverts

the code: function payoutWinners() public payable { require(msg.value >= payoutOwed, "send more than what is owed"); for (uint i = 0; i < winningAddresses.length; ...
snejad123's user avatar
2 votes
2 answers
121 views

Why does a contract store how much eth it's been sent, internally?

Beginner question: In one or two smart contracts samples, I've seen that a function is payable but the smart contract seems to hold its own state on the total it has received, e.g. total += msg.value. ...
Luke Puplett's user avatar
1 vote
0 answers
8 views

Instantiate contract from clone factory with value [duplicate]

I'm currently trying to create instances of a smart contract via a clone factory. The problem is, that I'm not able to send a value to the init function of the smart contract I'm trying to instantiate....
unsigned_int's user avatar
0 votes
1 answer
31 views

how to fix the phrase error: Expected ','but got ;

// SPDX-License-Identifier:MIT pragma solidity ^0.8.0; import "@openzeppelin/[email protected]/token/ERC20/ERC20.sol"; // The contract's name is "CryptoInsurancePolicy" contract ...
Brendan Shawn's user avatar
0 votes
1 answer
883 views

how does this honeypot works on BSC - it allows swapping from BNB but not reverse, can't even add BNB liquidity using it

This honeypot token can't even detected by Honeypot Detector tools, can I get a sense how does this honeypot works from contract level, so keep myself safe in the future? Scam Token (Do not buy!): ...
newbielearner's user avatar
0 votes
0 answers
26 views

solidity - why returned data not includes length

Let's imagine the following: /// to.call calls this function function fail() { revert("test"); } // (bool success, bytes memory response) = to.call{value: 0}(data); The way I understand is ...
Giorgi Lagidze's user avatar
0 votes
0 answers
23 views

What code is used to control an NFT collection's reveal date?

Some NFT collections reveal within days of mint. Others months. What generic source code script or function in Solidity enables an NFT contract creator to control when a NFT collection is revealed? If ...
user610620's user avatar
  • 1,486
1 vote
0 answers
113 views

How to code a zk roll-up in Solidity smart contracts?

Zksync is a protocol that recently enabled its layer-2 technology to directly admit layer-1 Solidity code for deploying on Zksync. Aren't zero-knowledge proofs difficult to code using Solidity ...
user610620's user avatar
  • 1,486
1 vote
2 answers
64 views

How can someone prove they are 18+ by smart contract?

Smart contracts are permission-less (no KYC) and decentralized, therefore, censorship resistant. IRL Smart contract applications range from ownership of digital paintings to proof of birth ...
user610620's user avatar
  • 1,486
1 vote
1 answer
32 views

delete keyword works wrong way

I have a storage dynamic array. uint[] public x1; It contains 4 elements (1,2,3,4) // Costs 22000 function test() { assembly { sstore(0,0) } } // costs 37000 function test() { delete x1;...
Giorgi Lagidze's user avatar
1 vote
2 answers
429 views

Smart Contract with private data

I'm looking for a way to have private data in an Ethereum smart contract. I explored the ZK space, could work on some scenarios but not totally private. I wanted to ask if you know new tools, sdks etc ...
m0j1's user avatar
  • 167
0 votes
1 answer
65 views

How to use ERC20 token for a Safe Remote Purchase contract?

I found a smart contract which performs a Safe Remote Purchase. The currency which is used for the payment is ETH. Here is the code: // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last ...
Federico Gentile's user avatar
0 votes
1 answer
24 views

Why do contracts have the ability to know whether the caller is a contract?

I see a lot of contracts around that block calls from other contracts. Seems to me like this prevents a lot of possible integration scenarios. Why was this ability built into the protocol?
user253751's user avatar
1 vote
1 answer
58 views

How Can I Give Priority in Transfer Function? (Solidity)

If two transactions has the same gas fees, I want to transaction which has minimum gas fees should have priority. uint minersTip = tx.gasprice - block.basefee; Here is transferForm method. Can i add ...
XcellentEEE's user avatar
0 votes
1 answer
342 views

how to emit an array of addresses in a solidity event

Good Morning Everyone, I have created a dAPP that sends ether to multiple addresses at once....but I have one issue, I am trying to create an event where all information about the transactions is ...
EniKay's user avatar
  • 3
0 votes
1 answer
35 views

Is it possible to write an inheritable extension contract that supports multiple parent implementations?

I'm writing an extension to be used with a ERC721 contract. Is it possible to call a function like balanceOf() which should be defined in any implementation of ERC721, without having to define the ...
Adam Linscott's user avatar
1 vote
2 answers
257 views

Using `call()` function returns false when trying to call function of a smart contract

I'm creating a test contract for calling external ones & ran into an weird issue with call() where it just keeps returning false. Being new to solidity, I'm not sure what is failing it. Here is ...
CoderMan's user avatar
0 votes
2 answers
40 views

How to store values ​with decimal places? [duplicate]

I need to calculate values ​​for percentage and I need them to have two decimal places and the minimum value is 0.00 and the maximum value is 100.00. When I use some decimal place, for example: 80.01 ...
THIAGO DE BONIS's user avatar
0 votes
1 answer
38 views

How to use others contracts in main contract?

I have two protected contracts, they are: _ Candidate _ Elector They're just using it to redirect their logic, as if they're "abstract"; And I have the main contract: ...
THIAGO DE BONIS's user avatar

1
2 3 4 5
42