Questions tagged [contract-design]

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

Filter by
Sorted by
Tagged with
0
votes
0answers
21 views

How to authenticate user details in smart contract? [closed]

I am building a login system in my dapp for which i have to check the details with already registered users .I tried it by getting user details in frontend and then authenticate it but i think it is ...
0
votes
0answers
12 views

Unbounded loop solidity internals

Under the hood, what happens in an unbounded loop? let's say I'm trying to send tokens to an infinite amount of addresses and end up with an out of gas error. Will the function which executes the ...
0
votes
1answer
12 views

Function not returning address when using web3 provider

I have a contract that works fine when only using remix. I needed to test the block size and block number. here someone suggested me to use ganache which I did but now I don't get the output I'm ...
0
votes
0answers
23 views

How to get a callback function to return to a separate contract? [closed]

Let's say I have the following structure: contract A { function getResult(){ unint256 result = B.getRandom(); } } contract B { function getRandom(){ // This function has a ...
0
votes
0answers
14 views

Can I make a delegatecall to a Solidity contract that is compiled with a higher compiler version?

Lets say that I have the contracts A and B. A needs to make a delegatecall to B. A is (for some reason) compiled with a compiler version that is lower than B's compiler version. Can I safely assume ...
0
votes
1answer
25 views

The below code gets compiled but when foo is called invalid opcode error is thrown

pragma solidity >=0.5.0 <0.7.0; contract Mycontract{ uint256 a; struct User { string name; } User[] users; function foo() public{ User storage user=users[0]; ...
0
votes
1answer
23 views

why x(function setArr) is not being returned?

pragma solidity >=0.5.0 <0.7.0; contract Example{ uint256[3] x; function setArr(uint256[3] memory y) public returns(uint256[3] memory){ x=y; return getArr(x); } ...
0
votes
0answers
32 views

Deliver a dapp to a client, how to set as owner?

So, as a freelancer that wants to make a smart contract for a client, how do you set such client as the owner of the contract? Would it be setting the owner variable to the eth address of the client, ...
1
vote
1answer
18 views

DApp Development- how to update dapp and keep existing data

Compare to web application that separate the application and database, we can update the application and keep the existing data. Could you suggest me how to update dapp and keep the existing data?
1
vote
1answer
21 views

How does array.length— work?

I'm having trouble understanding why people call array.length-- after deleting an element in an array (as seen in this answer and many others). Why is there need for doing so? When is the length of ...
1
vote
0answers
38 views

msg.sender and tx.origin - how to use them in practice? [duplicate]

I wrote a contract A that uses msg.sender for authentication: When A creates an item it stores msg.sender in itemsOwners mapping (itemOwners[itemId] = msg.sender;). Later A compares msg.sender to ...
0
votes
1answer
22 views

Issue with dynamic matrices in solidity

I have a matrix in solidity like that string x[][] I'm trying to write functions to return rows and colums The following code works well: // SPDX-License-Identifier: unlicensed pragma solidity ^0.6.0; ...
1
vote
0answers
12 views

Is gas cost of external calls included in gas cost of the main call?

When I call external methods of other contracts from my contract, is the gas fee of these calls included in the gas fee displayed by MetaMask? My transaction reverts (execution reverted) for an ...
0
votes
1answer
22 views

What is the cost of inter-contract calls?

I have a contract with methods to create items and add them to categories. I want to create a wrapper contract that would combine several calls into one: create an item and add it to several ...
0
votes
1answer
11 views

When a contract calls other contracts, is it an atomic operation?

If a contract calls several external methods of other contract(s), is it as a whole one atomic transaction (reverted as a whole if an exception happens)?
1
vote
1answer
124 views

Is Solidity being replaced as the de facto standard for smart contract development?

Is Solidity being replaced by languages such as Rust or other programming languages for smart contract development?
3
votes
1answer
32 views

How is Chainlink decentralized? [closed]

I believe one of the main criticisms of chainlink is that it is not decentralized enough, adding more nodes would be a big step in a positive direction. When I pull data through a node, that node ...
0
votes
1answer
22 views

When would one want to use a linked library?

My understanding is that if a smart contract consumes a library that only has internal functions, then the compiler will embed the library into the contract bytecode. At the lowest level, there is no ...
0
votes
1answer
46 views

how create address for each ethereum user [duplicate]

I have a group of Ethereum users how do I create an address for each user to send their data on the network?? I want a way to create addresses for each user??
0
votes
1answer
41 views

Deleting an array in storage (>= 0.6.0)

I need to add elements to a resizable myArray and then delete the myArray. I don't know what the length of myArray will be before the loop, and it's not possible to resize a memory array; that leaves ...
0
votes
1answer
18 views

When using mapping, why use an address over bytes32?

From an end user standpoint, they will never want to use the address for searching for mapped data when they could just submit a username for function parameters, so is there any specific reason why ...
0
votes
1answer
48 views

how different users write their data in ethereum network?

How a number of blockchain users save their data in the blockchain network using ethereum. Meaning more than one user sends his data using Python to save it in blockchain networl ?? How do I ...
0
votes
0answers
19 views

Compile error. Fallback function error

I use pragma 0.6.2. I am trying copile in truffle code which contain this lines: fallback() external payable{} I an getting error: The payable fallback function is defined here. fallback() external ...
0
votes
0answers
63 views

How do i withdraw Eth from a contract i created

New to blockchain.. havent a clue.. I managed to create a new contract with Eth. I moved money from MyEtherum Wallet to Metamask and into a contract, somehow? I have no coding experience but need ...
2
votes
1answer
33 views

Is the May 2017 contract creation attack still possible?

In May 2017, an "attacker" created a contract that attempts to create many other contracts(using many JUMPDEST operations in the creation bytecode) until it runs out of gas. I see the gas ...
0
votes
2answers
64 views

How do I give every user Ethereum an address and does it affect security

I have a project with Ethereum Blockchain the users send the data to the server and the server writes the data in the blockchain network My question is how do I represent the server in the smart ...
0
votes
1answer
55 views

Transfer money between contracts

I'm quite new at smart contracts/Solidity, which I'm learning for a postgraduate course. In one of the assignments, we have to implement a little competitive game (something like the game of Seven ...
0
votes
0answers
26 views

ERC-20 token with identitfication

I would like to create a generic ERC-20 token with identification. The token would only be transferred to previously identified addresses. The way identification is implemented should be as decoupled ...
0
votes
1answer
27 views

Should Try-Catch error handling be avoided for security? [closed]

What implications can it have to the security of a function if the content of it is wrapped into try-catch statements?
4
votes
2answers
92 views

Graph traversals on Ethereum, at scale

I read the Efficient Solidity storage pattern for a directional weighted graph thread, but that deals with storing graphs. I'm interested in techniques for how to traverse graphs in Solidity, at scale....
2
votes
0answers
42 views

SPDX license when importing other people's contracts

Since Solidity 0.6.8, the compiler started throwing warnings if a contract isn't annotated with a SPDX license identifier: // SPDX-License-Identifier: MIT contract MyContract { ... } Now, there'...
0
votes
0answers
10 views

Implementation Question for Licence Token

I am currently working on the idea of using token as licences for digital products. I am offering different documents and books in pdf format and want people to be able to buy them with ETH o.ä.. I ...
0
votes
1answer
41 views

Abstract contracts cannot be initialised, can they?

As of v0.6, solidity introduced abstract contracts. Do they behave just like in all other languages - that is, they can't be initialised, can they?
1
vote
0answers
20 views

How does zocrates process zk-SNARK step by step?

I'm trying to understand my zokrates code and how it processes zk-SNARK step by step in accordance to this article. The article breaks down the zk-SNARK into three steps. A key generator, G, takes ...
0
votes
1answer
55 views

What are the flaws of this example contract?

I am currently writing a paper/article on tokenization, in the beginning of which I introduce smart contracts. To this end, I present the following contract as an example: pragma solidity ^0.6.0; ...
0
votes
1answer
35 views

Multiple transfers, one smart contract

I have the following function in my contract: function AcceptOffer() public payable { if ( msg.sender != InstanceOwner ) { revert("You are not the owner of this ...
2
votes
1answer
43 views

Destroy smart contract and collect its funds

I'm quite new at smart contracts/Solidity, which I'm learning for a postgraduate course. In one of the assignments, we have to implement a short example of dutch auction (wiki link). Now my question ...
2
votes
0answers
25 views

Are there well-solved patterns and practices for handling errors in Solidity?

In the spirit of Are there well-solved and simple storage patterns for Solidity?... Are there known, battle-tested practices for how to deal with errors in large Solidity codebases? It's common in ...
0
votes
1answer
34 views

Nested Structs with Mappings Inside

I have the following code: // SPDX-License-Identifier: MIT pragma solidity >=0.4.22 <0.7.0; pragma experimental ABIEncoderV2; contract VenueRegistry{ struct Queue{ uint head; ...
2
votes
1answer
24 views

Why can I call contract methods containing a selfdestruct multiple times?

The following code is part of a Smart Contract I'm working with: [...] function noComplain() allowed(receiver, stage.keyRevealed) public { selfdestruct(sender); } // function ...
0
votes
2answers
85 views

How can I get the revert reason of a call in Solidity so that I can use it in the same on-chain transaction?

I want to get the revert reason of a failed call and then use that revert reason in the same on-chain transaction. Is this possible?
0
votes
1answer
16 views

1-To-M struct relationship advice *DApp Development

Let's assume that I'm building a property investment DApp. I have two entities involved in the DApp. Those two entities are 1) providers and 2) investors. Right now, a provider is able to offer 1 ...
0
votes
0answers
21 views

TransferFrom - User Experience Examples

Can someone provide some DApp examples where the transferFrom pattern has been implemented and does an at least 'decent' job of providing a good user experience. If not, what is then a convenient way ...
1
vote
1answer
31 views

Accessing contract functions from web3 and javascript

I have deployed a contract in a private blockchain using remix and ganache. Now I want to interact with it trough web3 and the console from my browser, but I'm not managing to interact with the ...
0
votes
1answer
43 views

Receive ERC20 token as value in function of smart contract

I want to receive an erc20 token as value for a function. Basically, the function caller defines an amount which will then be transferred from their balance to the smart contract. Which transfer ...
1
vote
1answer
35 views

Can't people be tricked into calling approve on an ERC token contract, and having their tokens stolen?

Most users of Ethereum and ERC tokens probably aren't aware of the existence of the approve and transferFrom functions. Couldn't users unknowingly call approve on an ERC token contract, and ...
0
votes
1answer
44 views

Security flaws in a simple smart contract

I developed a simple smart contract to store two privacy preferences for a user. I am testing and evaluating this contract on a private blockchain via Ganache. I am currently validating the security ...
1
vote
1answer
26 views

Can you activate Contract Functions just by receiving Ether alone?

Noob Question here. I have a Dapp that has no actual need of a web interface. What is the best way to activate functions if someone did something as simple as send Ether to an address it controls from ...
0
votes
1answer
34 views

Card Game - Smart Contract (Public Cards)

We want to implement a card game with EVM and Smart Contracts. After defining all-important game information we asked ourselves how we can include the cards in the Smart Contract but don't make it ...
1
vote
1answer
41 views

Precompiled contracts

So I heard that the precompiled contracts perform functions that are difficult to do using EVM opcodes. Does that mean the precompiled contracts are not written in EVM opcodes. Which language are ...

1
2 3 4 5
33