Questions tagged [contract-design]

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

341 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
1
vote
2answers
54 views

what's the difference between call and just using function?

Let's say I have a contract called contractA. It has the function: function bla(address test) { // way 1. test.call(abi.encodeWithSignature("first4bytes", arg1, arg2)) // way 2. ...
0
votes
1answer
26 views

Dynamically calling any other contract and function from contract

This gives a contract the same ability to interact with other contracts (with its address as msg.sender), as an externally-owned account, right? function call(bytes calldata _calldata) external ...
0
votes
1answer
18 views

DeclarationError: Identifier already declared

I'm getting the below compile error message: DeclarationError: Identifier already declared. --> contracts/coffeeBase/SupplyChain.sol:9:1: | 9 | import "../coffeeAccessControl/ConsumerRole.sol&...
0
votes
0answers
17 views

Effective way of doing data search in Ethereum Smartcontracts

Actually I am writing smartcontracts in such a way that I have upgradeable and non-upgradeable contracts. Lets say I have contractA_upgradeable.sol and contractA_nonupgradeable.sol. ...
0
votes
0answers
19 views

Does it cost more gas to call a function more than once in another function?

Does it cost more gas to call a function more than once in another function? For example: function getValue() public returns(uint){ return 5; } function getOtherValue() public returns(uint){ ...
0
votes
1answer
15 views

etherscan verification for newly deployed contracts

from my UI, I call a contract function through ethers.js that deploys a new contract. It's like user comes to the UI, clicks a button that calls a contract function and then, that contract function ...
0
votes
0answers
21 views

Contract's admin keys/ownership relations

I have debated with myself about smart contract's admin keys and ownership and how this can occur in different ways. I will try to point some of the findings that I have found: OpenZepellin community ...
0
votes
0answers
11 views

Creating Ethereum token collectibles

There are a few concepts relating to Ethereum collectibles that are a bit confusing. OpenSea allows users to create collections where they can upload artwork and give them characteristics like “green ...
0
votes
0answers
38 views

Contract factory for upgradeable erc721

I am trying to find some way for users to deploy an erc721 contract and would like to clone an implementation contract through a contract factory like eip-1167. However when the contract factory ...
0
votes
0answers
21 views

What's the purpose of 'initializing' and 'initialized' in OpenZeppelin's Initializable contract?

The OpenZeppelin Initializable.sol contract includes a modifier initializer() that shows: modifier initializer() { require(initializing || isConstructor() || !initialized, "Contract instance ...
0
votes
0answers
15 views

Swap ETH to WBTC or other alt coin

I am trying to create a smart contract for a gmae that is, If anyone send ETH to it's address, it divide the ETH value into two equal value and send equivalent WBTC of firs part to an address and ...
0
votes
1answer
16 views

Does import run just once upon deployment or does it continue to import as time goes on?

If github is hacked or disabled then the import would be corrupted. import 'https://github.com/OpenZeppelin/openzeppelincontracts/blob/master/contracts/token/ERC20/ERC20.sol';
0
votes
0answers
18 views

Is it bad practice to store contract addresses as state variables?

So, here's an example. Say there is a dapp that has contracts A and B, and B has a function that calls a function in A. In order for B to access A's code, B store A's address as a state variable, as ...
0
votes
1answer
11 views

Best way of storing multiple instances 'prototyped' by the same contract?

Let's say I want to create a Solidity contract: contract Book { string title; string author; function setTitle() {} function setAuthor() {} } and I want people to be able to call this contract to ...
0
votes
0answers
32 views

all remix read functions fail: call to X errored: [object Object]

I'm facing an issue with Remix IDE and MetaMask Kovan testnet interplay. All contracts, even a basic ERC20.sol contract returns following error i.e: "call to token.balanceOf errored: [object ...
0
votes
0answers
20 views

Forceful Gas Issue - UniSwap Router Issue - Swap Eth For Tokens

The code below continues to give me a forceful send / gas issue, I'm not sure what is wrong, what could be the issue? do I need to approve something? I've been stuck with this error for some time now. ...
0
votes
1answer
20 views

How to make your token safer without => setTaxFeePercent(uint256 taxFee) external onlyOwner()

if I understand correctly, this line allows the owner to adjust the fee afterward, so in the worst case, a rugpull is possible. function setTaxFeePercent(uint256 taxFee) external onlyOwner() { ...
0
votes
1answer
43 views

Why did Uniswap abandon Vyper?

Uniswap V1 was coded in Vyper. They switched to Solidity for the V2. Why is it so? Was vyper lacking functionalities that would have made impossible to code Uniswap V2 with it?
0
votes
1answer
36 views

I'm confused about decimals and total Supply with my erc20 token

I created erc20 token. I want total supply of 50,00,000. And I want to give 7% tax on every transaction. So if anyone sends single coin then, how can I get 7% and transfer remaining to receiver? For ...
0
votes
1answer
34 views

Coding a smart contract for people to easily start a trustless bet online. How to improve my smart contract?

so I really want to create a smart contract for the community to use - one where two people can easily and trustlessly make a bet between each other. V1 of the smart contract would be where two people ...
0
votes
0answers
9 views

How to model smart contracts?

So Solidity is contract-oriented, which is similar to OOP. However, there are some differences I'm realizing now. My problem is such that I have a contract called Agorum, which represents contracts of ...
0
votes
0answers
14 views

Best way for two contracts that know each other's address?

Example situation: contract A calls a function from contract B contract B only permits only contract A to call the function (no other address allowed) I know I could do this: deploy contract B ...
0
votes
0answers
60 views

smart contract payout scheme

recently I found myself working on a project that might just be perfectly suited to attach a token model to. For this to work, however, I need some knowledge on the feasibility of one of the aspects. ...
0
votes
1answer
27 views

Update Account Balances ERC20

Are there are any design patterns or gas efficient methods of mass updating user balances (for ERC20 tokens)? For instance, say I wanted to run a casino where, after Block number X, all of the ...
0
votes
0answers
21 views

Are there any raffle smart contracts and platforms for NFTs?

Instead of smart contracts that do auctions, is there any website or DApp that facilitates smart contracts for raffles? For example, a number of participants submit an entry payment, and the smart ...
0
votes
1answer
23 views

What is the Intent of smart contract and decentralization

I have just started on blockchain and found that there are two key benefits with Ethereum: smart contract and decentralization. I tried to understand the benefits they provide and why they could have ...
0
votes
0answers
14 views

Why does listing NFTs cost more than bidding on NFTs?

In the link below are current gas fees for doing contract interactions on two popular NFT platforms https://gas.metasync.app/ Why does it cost so much more to list an NFT for sale ($150) than it ...
0
votes
0answers
7 views

How are view/pure functions handled in upgradeable contracts?

I have read through some standards regarding upgradeable contracts like EIP-1538, EIP-1822 and EIP-2535, and it seems most of them rely on the proxy pattern where a proxy/storage contract with a ...
0
votes
0answers
6 views

In the context of Ethereum contract creation, what does “cyclic creation dependencies are impossible” mean?

I'm reading the official solidity docs and came upon this passage on Ethereum contract creation: "cyclic creation dependencies are impossible", followed by the example code below (and also ...
0
votes
0answers
19 views

passing left for uint256

I'm trying to use this method: function test(uint amount) public { address(0xf5eA38B6b9644224dA1aECbC1219e8543c0689b2).call(abi.encodeWithSignature("deposit(uint)",amount)); } ...
0
votes
0answers
32 views

HOW DO I TRANSFER MY VOX COIN FROM A CUSTOM ADDRESS WITH DECIMAL 6 TO A ADDRESS WITH DECIMAL 18

I have Vox coin but on a contract address and with decimal 6 and on Smart Chain Network.. I transferred my coin to another Vox coin wallet with Decimal 18 but show as 0.00, if I should add custom ...
0
votes
0answers
18 views

How to implement multi-sig that allows only specific signer to pay gas

In case of simple multi-sig structure, I found that each signer have to pay gas to be executed. However, is there any references that allows only specific signer to pay gas? Any advice would be ...
0
votes
0answers
8 views

How to race condition attack where another party can make my transaction invalid?

I am working on a pub/sub contract. Publishing involves posting (on chain) a message encrypted to each paid subscriber. The publisher must publish a message for each subscriber or the transaction will ...
0
votes
0answers
17 views

How storing private key in blockchain is secure (FADB paper by Hui Li)?

I am a newbie in blockchain and smart contract. I was reading the following paper. FADB: A fine-grained access control scheme for VANET data based on blockchain https://ieeexplore.ieee.org/stamp/stamp....
0
votes
0answers
30 views

How smart contract can take secret key from a user interacting through client?

I am coming from a traditional web background and is a very newbie in smart contracts and ethereum and have a basic question. Please excuse me if it is too obvious but I am struggling to understand ...
0
votes
0answers
16 views

How many iterations can I make per a loop inside Solidity's view (or pure) function?

Lets say that I have a view function that has a loop and that I must use this loop. This loop is calling another view function to verify some data per index key. The view function is free to execute ...
0
votes
0answers
27 views

approval ERC20 standard front-running

In the following article Link, we read: Token owner just needs to make sure that first transaction actually changed allowance from N to 0, i.e. that the spender didn't manage to transfer some of N ...
0
votes
0answers
18 views

how to get the list of tokens that are specific to my requirements

Some of the tokens, have the weird approve methods. Meaning that they tried to mitigate front-running. https://docs.google.com/document/d/1YLPtQxZu1UAvO9cZ1O2RPXBbT0mooh4DYKjA_jp-RLM/edit I am trying ...
0
votes
0answers
4 views

tracking state changes via function calls that does not include event usage

Is it possible to track changes made to a smart contracts via its functions if the functions are not emitting events. I suppose if I know the function signature representation, then I should be able ...
0
votes
0answers
14 views

Using Solidity to write a contract that uses an existing token

I am trying to learn Solidity. I recently did this tutorial here: https://ethereumdev.io/transfers-and-approval-or-erc20-tokens-from-a-solidity-smart-contract/ I found it very informative. I was ...
0
votes
0answers
14 views

What are the advantages of selfdestruct-ing a smart contract?

I know this might be a subjective question but I am trying to understand why the ability to selfdistract a contract exists. What is the use of self distract? Are there any dapps using self distract as ...
0
votes
0answers
14 views

How can a contract interact with other chains?

Reading the Waifusion postmortem article this caught my eye: At the same time, we were made aware of multiple parties that were going to fork us as soon as we went live with a sale on BSC. This has ...
0
votes
1answer
20 views

Array of Struct

I have two structs - property and owner. struct owner { string ownerName; string ownerID; } struct property { string location; uint sqFeet; owner[] owners; } I want to ...
0
votes
0answers
37 views

How do I access data in another contract/node?

I have two contracts - Data.sol and Buy.sol. Data.sol contains information on products, etc. I want to use Buy.sol to get and update data in Data.sol, somewhat like having a database. I know this can ...
0
votes
0answers
12 views

Need some feedback/critique on a smart contract that allows anyone to send Eth and split it (50:50) with two other accounts

pragma solidity 0.8.1; contract splitFunds { mapping(address => uint) public beneficiaryBalances; address[2] public beneficiaryList; event LogReceived(address sender, uint amount); event ...
0
votes
0answers
9 views

Continuous Funding Chainlink VRF Oracle activity

What is a good way to fund a project that implements a function that pulls chainlink VRF data for random number generation? I don't want the function to stop working because of no more funds left, ...
0
votes
1answer
18 views

How can I log text (and see the logs)

I'm writing a contract using remix, and I'm hitting an error but I can't debug it. When I enter the transaction hash in remix it tells me the json is empty (""). I'm testing on the ropsten ...
0
votes
1answer
40 views

Why this delegatecall attack not working?

I am confused by this simple contract. The main purpose is to bypass the OnlyContract() modifier. Victim contract. pragma solidity 0.7.6; contract Victim { modifier OnlyContract() { ...
0
votes
0answers
99 views

test return value of transaction

contractA function test() internal { stateVariable = 20; uint num = 20; assembly { mstore(0x00, num) return(0x00, 0x20) } } How do I test the return ? I am using hardhat , but i don'...
0
votes
0answers
123 views

How to implement crypto refunds in a smart contract?

I am quite new to cryptocurrencies and after some investigation I thought this might be the right place to ask. Problem: I have a small business and I would like to offer to my customers the option to ...

1 2 3
4
5
7