Questions tagged [contract-design]

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

Filter by
Sorted by
Tagged with
0
votes
0answers
2 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
1answer
44 views

Does this simple smart contract look secure?

https://pastebin.com/5Gk7Q6FW Any obvious vulnerabilities? Thank you.
0
votes
1answer
11 views

How to handle memberships of multiple users of a scheme

I am very, very new to blockchain development and even newer to Ethereum. Have done / am doing some online course though... Anyway, how would one handle the situation where you might have a scheme ...
0
votes
0answers
13 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
9 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
21 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
1answer
10 views

how to ensure the atomicity of multiple inter contract transactions

I am creating a contract to buy and sell different tokens in batches. and i want to ensure that all the transactions that would buy or sell the individual tokens, either pass or fail. my code would be ...
0
votes
1answer
10 views

Why should a function direct its implementation to another function in the same contract?

I'm pretty sure there're similar questions here, but I just couldn't find them with the correct keywords. I found the following code in the Uniswap V2 core contracts, and I'm not sure why both ...
0
votes
0answers
9 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
12 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
18 views

How can I change the logic of _safeMint method in a child contract of ER721?

I was fiddling with OpenZeppelin ERC721 contract and created my own contract inheriting from the ERC721.sol. I tried to change the _safeMint method, so I copied it from the parent contract and this ...
0
votes
1answer
24 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?
1
vote
1answer
22 views

Burn function without emitting Transfer to address 0

I have found some code samples for "burn function" on token contract. In this function, burn amount is substracted from the balance and then "Transfer Event" is emit to address 0. ...
2
votes
1answer
86 views

How much gas do 0x00000000… addresses and 0x00000000 methods really save?

I have seen many contract addresses being created using vanity address generators to have many 0s in the begginning and even method sighashes having all 0s in them and have come to the conclusion that ...
0
votes
1answer
38 views

Set msg.sender in testing

I have a Solidity function that manipulates an object. The function only allows this manipulation of the caller msg.sender is owner of that object. Something like this: function Manipulate(uint i) { ...
0
votes
0answers
30 views

How to design Ethereum contracts for supply chain traceability?

Like many before me (and certainly many after me) I am looking at the usage of smart-contract blockchain within the Supply Chain context. To that end I would like to implement this example completely ...
0
votes
1answer
18 views

Why would the type byte[] waste 31 bytes of space for each element?

The Solidity Docs (v0.8.4) states: The type byte[] is an array of bytes, but due to padding rules, it wastes 31 bytes of space for each element (except in storage). It is better to use the bytes type ...
1
vote
1answer
26 views

Why virtual functions without implementation cannot have modifiers?

Trying to compile the code pragma solidity ^0.8.0; abstract contract Test { event functionCompleted(address indexed); modifier emitter(address x) { _; emit ...
1
vote
2answers
32 views

What's the default erc20 decimals?

As we know, decimals is an optional parameter on ERC20. I was wondering what if decimals is not set on a contract. Does it mean that if I send 10 in the transfer function, it means that it actually ...
0
votes
1answer
27 views

How to make a smart contract which pays out only if a service is performed?

Hello I am new to the world of solidity. I am trying to create a smart contract with the following conditions: a customer wants to buy a service/product from a retailer (me). the price of my service (...
1
vote
1answer
16 views

Do contract size increase with gas in block?

I'm trying to deploy a contract with REMIX but it throw an error "smart contract too large, not enough gas". Is REMIX hardcoded for contract size ? Do smart contract size increase with ...
0
votes
1answer
18 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 ...
1
vote
2answers
60 views

How can msg.sender == address(this)?

I know that msg.sender will be the address that connects to the contract. Address(this) is the current contract address Then == means it connects to itself. When using this condition in require, the ...
0
votes
1answer
22 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 ...
1
vote
1answer
16 views

Token pegged to the average return of ex top 10 cryptos

summer is coming up and I'm taking some of my vacation time to develop a crypto currency of my own. I'm looking to create a token that has a return pegged the average of for example the top 10 ...
0
votes
1answer
7 views

Do I have to include every method in an interface?

I'm using a 3rd party contract in one of my contracts. I've created an interface for the 3rd party, do I have to include every external method in the interface, or just the ones that I need to use in ...
1
vote
1answer
134 views

A Lottery Solidity Smart Contract that accept erc20/bep20 token instead of ether to enter the lottery

function enter() public payable { require(msg.value > .01 ether); players.push(msg.sender); } Change this function to accept erc20/bep20 token to enter the lottery
1
vote
1answer
19 views

Are there any resources for “contract-oriented programming”?

Contract-oriented programming, like Solidity, is similar to OOP, in a syntactical sense. For example, both have concepts of encapsulation, abstraction, inheritance, and polymorphism. They also share ...
0
votes
1answer
40 views

How to retrieve ETHs sent to a contract?

Lets see this simple contract: contract MyContract { receive() external payable { require( msg.value > 0 ); // Thank you but how can I take this ETH later if I need (not now)? ...
0
votes
0answers
8 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 ...
1
vote
1answer
46 views

How to Add a Function to an Already Deployed Smart Contract

I have already deployed a contract on Binance Smart Chain. I now would like to add time lock functionality to this contract to lock some of the tokens for a time period. I know that smart contracts ...
0
votes
0answers
15 views

What is the meaning of decentralization?

In persuit to understand blockhain decentralization: If I am not wrong, it helps prevent control with one entity. Consider a hypothetical example of a service which takes a string and returns a ...
0
votes
0answers
12 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
41 views

Determine number of holders in solidity

I saw a lot of questions over the internet on how to determine the number of token holders in solidity and everybody says that its impossible to be determined without interacting with a solution that ...
0
votes
0answers
59 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
21 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
18 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
13 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
17 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
1answer
35 views

Trying to burn 1% off each transcation

Can anybody show me how to add a code for burning %1 of each transaction? https://github.com/strainzeh/MADToken/blob/main/MADToken.sol
0
votes
0answers
30 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
17 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 ...
1
vote
1answer
21 views

How to replicate pushing and deleting from an array of structs from Solidity in Vyper?

I'm trying to re-create a Solidity contract in Vyper for a demonstration and am trying to figure out the best way to replicate adding/removing from an array of structs... As far as I can tell I'd have ...
0
votes
0answers
7 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
29 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
1answer
244 views

Automatically tax transaction and distribute to all token holders

Is there an efficient way to automatically "tax" every transaction and proportionately send the taxed amount to all non-blacklisted token holders? From my understanding, looping through all ...

1
2 3 4 5
37