Questions tagged [contract-design]
for high-level questions about the choices made during contract construction
2,075
questions
1
vote
1
answer
43
views
getting address field from assembly
Assume the following solidity code:
function caller(uint k, uint v) public {
(bool success, ) = address(this).call(abi.encodeWithSignature("callee()", abi.encode(k, v, msg.sender)));
...
0
votes
1
answer
43
views
Transaction Hijacking?
So I created a wallet and sent it some funds then I submitted a few invalid transactions. I approved the correct address for transferring wrapped eth. After the approval my script immediately sent the ...
3
votes
1
answer
64
views
What's type hash's usecase in EIP-712?
Assume I'm implementing EIP-712 signatures in solidity.
contract Nice {
bytes32 private constant BID_TYPE_HASH = keccak256("Bid(uint256 num1,uint256 num2)");
struct Bid {
uint256 ...
1
vote
0
answers
15
views
How can I design smart contracts for p2p vehicle trading?
The idea is to have two contracts:
OrderManager Contract
NFTMinting Contract
OrderManager will manage the funds transfer for the vehicle; buyer will deposit the funds, the seller will withdraw them; ...
1
vote
2
answers
65
views
msg.sender vs owner
Is it bad practice (or risk prone) to use owner instead of msg.sender when checking actions initiated by a caller?
...even if I check that owner is authorized by msg.sender to do the mentioned actions?...
0
votes
1
answer
29
views
Will upgrading a smart contract to inherit from a new base class cause potential storage conflicts with UUPS proxy pattern?
I have an ERC20 contract like so:
contract myToken is ERC20BurnableUpgradeable, OwnableUpgradeable, UUPSUpgradeable, PausableUpgradeable
{
mapping(address => uint256) public totalSpent;
...
0
votes
0
answers
14
views
there is a bot code on you tube [duplicate]
there is a bot code on you tube, where can i go to check if its a scam> here is the code.
code:
https://codepastes.com/raw/wJLpHt
you tube:
https://youtu.be/a2oGKFSWhuk?si=gJiqVdatk17qXi2f
0
votes
0
answers
30
views
My contract level metadata is not showing on Opensea!
I need some help I'm new to solidity and I'm reading the docs for opensea, but I must be missing something. I have an ERC721 contract on Polygon, but the contract level metadata won't show. I'm ...
0
votes
1
answer
20
views
re-revert error data with non-external function
my question is how what if one of swaps in doSwapChain revert how i can re-revert that error(UniswapV2 error) with my error that have the index number of the swap and also the error that reverted(...
1
vote
3
answers
68
views
Transanction rejected by EVM when i tried to call a claim function from an airdrop contract
This my contract /**
contract JayTechAirdrop {
address public owner;
address public jayTechTokenAddress;
uint256 public claimAmount = 1e6 * 1e18; // 1 million JayTech tokens
uint256 public gasFee;
...
0
votes
0
answers
28
views
Efficient Storage Strategies for ERC721 with Editable Content
I'm just starting to learn about smart contracts, Ethereum and NFTs. It's all new and I need your help with managing editable NFTs.
I want to create a NFT with content that is easy to modify while ...
0
votes
1
answer
31
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 ...
0
votes
1
answer
82
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/...
0
votes
0
answers
12
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....
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 ...
3
votes
2
answers
69
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? ...
0
votes
1
answer
34
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: ...
0
votes
1
answer
19
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 "...
1
vote
1
answer
77
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 ...
0
votes
1
answer
211
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 ...
0
votes
0
answers
25
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
0
votes
0
answers
23
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 ...
1
vote
2
answers
76
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 ...
0
votes
1
answer
29
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 ...
0
votes
0
answers
90
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 ...
0
votes
1
answer
351
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 ...
0
votes
1
answer
333
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 ...
2
votes
1
answer
113
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 ...
0
votes
0
answers
80
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 ...
0
votes
1
answer
19
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 ...
0
votes
0
answers
30
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 ...
1
vote
1
answer
2k
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 ...
2
votes
1
answer
64
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 ...
2
votes
2
answers
396
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 ...
2
votes
2
answers
297
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 ...
1
vote
1
answer
186
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 ...
1
vote
1
answer
29
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 ...
0
votes
1
answer
49
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 ...
1
vote
0
answers
43
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 ...
1
vote
1
answer
17
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; ...
2
votes
2
answers
148
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.
...
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....
0
votes
1
answer
33
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 ...
0
votes
1
answer
1k
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!):
...
1
vote
0
answers
119
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 ...
1
vote
2
answers
72
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 ...
1
vote
1
answer
37
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;...
1
vote
2
answers
509
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 ...
0
votes
1
answer
74
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 ...
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?