Questions tagged [contract-design]
for high-level questions about the choices made during contract construction
2,043
questions
0
votes
1
answer
9
views
"yarn hardhat run scripts/propose.ts --network localhost" - Console.log not working?
Can anyone spot some an issue that may be preventing my console.log to work in this file i have created in my script folder?
What i am doing is first opening terminal #1, and running npx hardhat node. ...
1
vote
1
answer
18
views
What's the probability of getting the same signature using ECDSA?
If I hash the message "HELLO" - keccak256("Hello")
then run it to a ECDSA, what's the probability that I will get the same r, s and v value everytime?
Do I need to add some unique ...
0
votes
0
answers
5
views
Utilizing and Monetizing existing NFTs using Magazine
I’m working on a side project, A Meta Magazine, featuring NFTs only. This is a collaborative project
which utilizes existing NFTs. Entire Mag will be made out using NFTs, including cover pages, ...
0
votes
0
answers
8
views
Storage design for a social network
I want to create a social network app using Solidity, but I am having a hard time thinking of the storage design. Using this link:
Are there well-solved and simple storage patterns for Solidity? as a ...
1
vote
0
answers
109
views
+50
Update HashMap within onERC721Received with Vyper
When a contract receives an NFT by calling safeTransferFrom, onERC721Received is automatically called on the receiving contract. I want to be able to update a Hashmap to record the address of the ...
0
votes
1
answer
20
views
A few simple question about using interfaces vs. standard contracts (IERC721 vs. ERC721)
1.)Is it correct to say..... if i import ERC721.sol into my contract then all the ERC721.sol functions are accessible even if i don't list all the functions in the contract? Meaning... i don't ...
0
votes
1
answer
22
views
Solidity interface error
I am trying to connect two different Smart Contracts using interfaces. Here is my contract CRUD.sol: // SPDX-License-Identifier: MIT pragma solidity ^0.8.4;
contract CRUD {
struct Data {
uint id;
...
0
votes
1
answer
20
views
ecrecover returns incorrect address
I use these contract functions to verify signed message:
function verify(
address to,
uint256 amount,
uint256 nonce,
bytes memory signature
) public view returns (...
0
votes
1
answer
13
views
Multiple inheritance in Solidity
I have a contract C that is Ownable so I can use ownerOnly on its admin functions.
Recently, I added some functionality that I'm going to start using in other projects. I refactored the functionality ...
0
votes
2
answers
37
views
Solidity interface between two contracts
i am trying to connect two different Smart Contracts. On one hand I have CRUD.sol, which implements CRUD operations in a struct "Data". I have programmed a method readAllData() that returns ...
2
votes
1
answer
141
views
How did the contract size grow after removing couple of lines?
This is surely not a general case, but a specific one.
I have a large smart contract (22.572 KB) and I am trying to make it smaller.
Here is a chunk of the contract:
modifier onlyValidTokenId(...
0
votes
1
answer
9
views
How to get price data for a redeem without using chainlink
Trying to make a ecosystem where you have two tokens (Token X, Token Y) Token X can be minted for $1 worth of Token Y burned. And Token X can be redeemed for $1 worth of Token Y. How would I do this ...
0
votes
1
answer
27
views
Can we take the fees from seller and not buyer in 0x v4?
In v4 it was introduced that fees are paid by the buyer, denominated in the asset paid by the buyer, and are paid in addition to the erc20TokenAmount specified in the order.
https://docs.0x.org/nft-...
0
votes
2
answers
26
views
How to write a getter function for an array of structs? "storage ref[] storage ref is not implicitly convertible to expected type uint256[]"
I'm developing an app that allows user to make bets against each other.
In order to get some useful web-UI info, i need to write a getter function for an array of structs.
Simplified version of my ...
1
vote
1
answer
28
views
How can a contract confirm the off-chain sorting
Suppose a mapping of addresses and their respective balances. I would like to recover a list of the top "k" addresses by balance.
I understand that sorting inside the contract is prohibited ...
0
votes
2
answers
43
views
Implement splitting payment in ERC-20 token
I am new to this topic. I'm trying to implement a method to split the payment inside the token contract itself. I know that there is a separate contract for payment splitting, but I want to try to ...
0
votes
1
answer
21
views
Are smart contract constructor arguments hidden?
I want to know if it's possible to decode a smart contracts creation arguments.
I know that if you are calling a normal function of a contract, you can decode the arguments provided if you have access ...
1
vote
0
answers
21
views
Does smartcontract make sense in a truely trustless world?
How can a common person verify the smart contract code is not a scammy code?
We can never have a smart contract that is feature ready all at once or even bugless. An upgradeable smart contract is done ...
1
vote
1
answer
125
views
Why does a constant function that reads a struct memory cost the same as accessing the struct member directly?
Context
I have recently introduced a new constant getter in my contract, and I have thought that that it would lead to an increase in gas costs. Below you can find those snippets of code that ...
0
votes
1
answer
66
views
How are Public Name Tags regsitered on Etherscan?
How are Public Name Tags given to contracts? Are they purchased by the team issuing the contract, who verifies them and what is the process behind it?
Also, is there a way to see what contracts got ...
0
votes
1
answer
22
views
NFT tokenID question
I've got an ERC721 contract as part of a larger react dApp. My app is connected using web3 tools to the user's wallet. I need to be able to see if the address connected has a token balance for my ...
1
vote
0
answers
87
views
How to implement ERC721Receiver with vyper v0.3.3
I am trying to implement a function, onERC721Received, using Vyper v0.3.3, that is called when an NFT is transferred to the contract using safeTransferFrom. According to the this ERC721 token standard,...
1
vote
1
answer
82
views
How to transfer an NFT from a contract address to a wallet address
In a local test environment, I am able to compile this implementation of the ERC721 token standard, deploy it, mint an NFT and transfer it (using the transferFrom function) to the following deployed ...
2
votes
1
answer
116
views
Upgradeable proxy contracts- Seperating logic, functionality, & storage contracts. Examples? Resources?
I understand one of the best ways to make your contracts upgradeable is to separate into 3 separate contracts and send via delegate call from the proxy to the functional contract. The design is ...
0
votes
0
answers
20
views
why would I need to call `ens.resolver()` on chain?
I was reading the following link and somehow, the question popped up in my head.
It suggests that - transforming from string name to bytes32 _node should happen off-chain. Let's just assume that this ...
0
votes
1
answer
96
views
Downsides of using ERC721A over ERC721?
At our project we're still contemplating wether to ERC721A over ERC721Enumerable.
It's important for us to have stability. So has ERC721A proven so far that it's stable?
I'm looking forward to answers ...
0
votes
1
answer
27
views
Please help me find what this function does? Is there is a way around it
I was able to locate this piece of code in a contract that automatically sends the token you buy into the dead wallet.
function swapExactTokensForETHSupportingFeeOnTransferTokens(address account, ...
2
votes
1
answer
72
views
Upgrade of storage within proxy system
In a proxy system, where the implementation is in one contract and the storage in another, what would be the most efficient way to upgrade the storage contract (aka move the storage from that contract ...
1
vote
1
answer
92
views
EIP-2612: Why doesn't it use `_transfer` instead of approvals
I am looking at EIP-2612..
Permit mostly will be written as the following:
function permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external {
...
0
votes
0
answers
23
views
Which artifacts are needed for a deploy to vercel?
There's a ton of files that get generated with npx hardhat compile. I need to deploy the ABI for my contract to vercel, but I'm not sure which of these files I can .gitignore to keep the diff small on ...
0
votes
0
answers
25
views
When I run `npx hardhat compile`, can I output it to a different directory?
Looking to compile contracts in a structure similar to
- artifacts/mainnet
- artifacts/network-a
- artifacts/local
0
votes
0
answers
20
views
Disburse Dividends to individual address?
So I have a contract where dividends are disbursed to all holders. This works great. But i am trying to add a function where in certain scenarios specific holders get a "bonus" of dividends ...
0
votes
1
answer
35
views
Randomly shuffling a mapping in Solidity
I am trying to randomly shuffle a mapping in Solidity. As I understand, this problem has 2 parts:
Generating a random number in a smart contract using a secure manner
Shuffling the mapping - I'm more ...
0
votes
1
answer
20
views
dispersing funds from contract to addresses
I have a contract with some funds in it and I'd like to equally transfer these funds to addresses that are held in an array. For example, 3 ether in the contract would mean that 1 ether go to each ...
0
votes
0
answers
24
views
Why is it is "i + 1" in this forLoop and not "i"
Can anyone tell me why the if statement in this function.... if(idToMarketToken[i + 1].owner == address(0)) is using i+1 and instead of i? Why doesn't "i" alone work?
function ...
0
votes
1
answer
17
views
Record events on-chain
I want to record certain events on chain, so there is later no dispute that party X indeed logged events E1, E2 etc at times T1, T2 etc. Most of these events will essentially be hashes of certain off-...
0
votes
0
answers
26
views
Is this an application for ERC721 or ERC1155?
I am in the process of planning my first smart contract and trying to decide if I should use ERC721 or ERC1155. Any help from someone more experience on the subject would be much appreciated!
Here is ...
0
votes
1
answer
35
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
91
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
169
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
74
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
47
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
96
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
13
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
18
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
55
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
24
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
16
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
18
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
31
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 ...