Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [contract-design]

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

0
votes
2answers
22 views

Compare bytes32 and string using solidity

I need to compare a bytes32 value with a string. In the below example I need to check if QRVal==QRScanVal. Eg: bytes32 QRVal="0xc59aa6848d32d073bdcaa041b2735d3e4546d0836498e30de7c4c64c50933a33"; ...
3
votes
3answers
179 views

Handling decimals in somewhat complex math

I'm a bit lost on what to do with the following calculation. The problem is that decimals are being round up/down, which obviously doesn't give me the result I desire. int totalValue = 275000; int ...
3
votes
1answer
29 views

Ganache + Truffle: how to deploy a contract without considering the gas

I am working with Ganache and Truffle. I am trying to deploy kind of a huge smart contract, but most of the functions in this smart contract are pre-prod functions, so I do not really worry about real-...
1
vote
1answer
36 views

Developing a CRUD database in Solidity

I want to implement a database in a private blockchain. It consists of four tables and my idea is to use four smart contracts, one for one table. For each table i'll put the corresponding attributes ...
0
votes
1answer
25 views

Storing encrypted data and decrypt on-chain

The idea was to store the encrypted number of tokens,and when user was sending his private key, smart-contract would decrypt the data and perform an action of sending tokens to someone else. The catch ...
0
votes
1answer
28 views

Multisig function calls

I am making a dapp in which ethereum user accounts that call certain functions are rewarded with an ERC20 token. All the dapp is based on functions using only one ethereum account as parameter. But if ...
1
vote
2answers
25 views

Mapping primary key of each struct in array to them-self

pragma solidity ^0.4.17; contract Campaign{ struct Transaction { address Creditor; uint Amount; } Transaction[] public Transactionss; mapping(address => Transaction) ...
0
votes
1answer
35 views

Is there an issue using event overloading and event logs that contain arrays?

My event fires, but the last parameter is never logged. It appears as if it doesn't even exist. Here is my solidity code: pragma solidity >=0.5.6; contract EventTest { event marketCreated(...
3
votes
1answer
35 views

How is The Graph a decentralised solution?

I understand that querying for data on Ethereum is a pain in the neck and that The Graph indexes events so that developers can more easily get their most precious blockchain data. However, I'm not ...
0
votes
2answers
27 views

msg.sender.balance inside contract

what does/should msg.sender.balance return when used inside contract? Assume we have contract A, calling B, which is calling C. msg.sender is propagated with the calls down to B and C The user is ...
1
vote
2answers
36 views

How can we detect if tokens are transferred to our smart contract and avoid “allow”?

Imagine you have a smart contract that accepts all forms of ERC20s. You want users to call a function by which they will send you their ERC20s and in exchange receive a greeting. Technically we can ...
1
vote
1answer
13 views

Verifying signed typed message hash on-chain

I've seen many instances of verifying signed messages in which the hash to be verified gets passed as an argument. I need to first recreate the hash on-chain, before running ecrecover on it. However, ...
1
vote
2answers
175 views

Reason for check of msg.value > 0

I came across published smart contracts (like this one from ConsensSys) that check whether msg.value is strictly larger than zero in their payable functions. After wondering whether msg.value can be ...
0
votes
1answer
24 views

When I create contract using another contract how could I access his methods in web3js?

Hey I have file 'contractFactory.sol' inside this file I have contract contractFactory{ event contractCreated(string name, address institution, address parent); function createContract( ...
0
votes
0answers
25 views

How to auto-execute smart contract's function by Aion or other method in the private chain?

I was a little bit confused about Aion scheduling system, because I want to do it on the private chain, in the example https://github.com/ETH-Pantheon/Aion, they have both smart contract Aion and ...
1
vote
1answer
28 views

How does contract of dapp figure out who buyer is?

How does contract of dapp(eg. market place) figure out who buyer is? If buyer wants to purchase servive(or product) at certain dapp, he should transfer tokens to contract address of the dapp. At ...
0
votes
0answers
14 views

Segregating Data and Code

After knowing Ardor platform, I was wondering if there are any plans for the Ethereum Community to segregate contract code execution from its data. The point is the same contract code could be used ...
1
vote
1answer
21 views

Hashnot matching generated from solidity contract and web3js

I want to make hash same as generating by solidity contract from web3 or ether's js. In solidity contract hash generation by below : sha256(abi.encodePacked(no of parameters)). Kindly help for it. ...
0
votes
1answer
27 views

Is it possible to modify privateFor addreses in a private Smart Contract (Quorum)?

I know how a private smart contract works providing a list of accepted addreses to privateFor property, but what if I want to disable (or enable) any address visibility? Should I deploy a new Smart ...
0
votes
1answer
24 views

Smart contract method relayer

I was wondering if there was a way, in theory, to call from a sc two functions from a secondary sc in which the result from the first function is a parameter of the second function so something like: ...
0
votes
2answers
39 views

Deploying smart contract with undefined state variables

I have a factory contract (Factory.sol) that creates new contracts (YourContract.sol). The createNewContract function in the factory defines some state variables that the new contract picks up in its ...
1
vote
1answer
29 views

Struct member access in web3 requires additional dummy field

If a struct contains a single field, then that field is inaccessible from web3. In the below example, field uint b must also be present in order to access field uint c from web3. Of course, it's not ...
0
votes
2answers
19 views

Check a user's address when accessing the agreement

I am developing a contract where a predetermined address can change a contract variable. The structure of my current contract is as follows: pragma solidity ^0.5.0; contract privacyPreferences { ...
0
votes
0answers
28 views

Error for ERC20 transfer The constructor should be payable if you send value

I have two contract 1) ERC20 contract 2) ERC20 token registry contract which is invoking my token contract and making a transfer function call to the token But function call is ending up with an ...
0
votes
2answers
59 views

How can the smart contract auto execute the function in the private chain?

I know currently, we can use the Ethereum Alarm Clock and Aion scheduling system to execute the function automatically, but according to what I know, it only can work in Main Net and Test Net(Rposten)....
0
votes
2answers
20 views

How to restrict ICO investors to redeem their ERC20 tokens while not restricting them to trade tokens among themselves?

We want to create an ICO where investors can purchase ERC20 tokens anytime but have to wait for atleast 3 months from the date of purchase in order to redeem/encash them on our platform. But we do ...
0
votes
1answer
23 views

Contract change registry

If i have a smart contract stored on block 10, when i change the status of this contract, the altered contract will be stored on the next block or the status of the contract will be stored in block 10 ...
1
vote
1answer
24 views

add fields to ERC721 tokens, still belongs to the standard?

if starting from the code of an erc721 token, I add fields beside the name, symbol and URI, is it still a token that respects the standard? Add in the contract, not in the JSON file. The most ...
0
votes
2answers
15 views

Problem making solidity contract compatible with version 0.5.0 or higher

pragma solidity >=0.5.0 <0.6.0; contract Courses { struct Instructor { string age; //add memory to struct varibles string fName; string lName; } ...
1
vote
1answer
21 views

is there a list type in solidity?

I know there are dynamically sized arrays, but I need a data structure that can remove elements from the middle cheaply. Using pop() with a dynamically sized array should require a shift of every ...
0
votes
1answer
31 views

CREATE / CREATE2 Verification

Where do I verify whether a contract has been created with CREATE or CREATE2, would I have to disassemble the contract and look for a CREATE2 opcode in the contract creation code?
1
vote
1answer
42 views

Enigma “secret contract” and concealing transactions history: How is it possible?

Enigma protocol is a second-layer, off-chain network that aims to solve privacy issues in blockchain. However In Enigma blog, there is an article (Link to Article), explaining the secret contract, ...
0
votes
1answer
24 views

map multikey how-to?

I'm trying to create a map whose key is composed of two bytes32 keys. I've tried with tuples-keys and struct-keys but both are rejected by the compiler. I'm also thinking about "hashing" both keys ...
0
votes
1answer
38 views

Sending private key to server side

I am trying to build new Dapp application for our startup by using web3j , I am facing an issue with signing the transaction from server side , because i need to know the private key for the client (...
0
votes
2answers
17 views

Std set in solidity?

Is there any way or library to have a set in solidity that can be iterated like C++'s std::set? library Set { // We define a new struct datatype that will be used to // hold its data in the ...
1
vote
1answer
16 views

reverse crowd sale possibility

Is it possible to do a reverse crowd sale? e.g. send tokens to a smart contract to get ether back. Or would this require to load the contract with WETH or something in advance?
5
votes
1answer
50 views

What is WETH and why can't we just use ETH?

can someone explain why we need WETH? what's the purpose of WETH, can't we just use plain ETH? it's not like it removes the tx fees or something. Hopefully someone can shed light on the concept.
1
vote
1answer
102 views

How to prevent selfdestruct from another contract

I have a contract A calling another contract B Contract A contract A { function sendValue(B _externalContract, uint _value) { _externalContract.acceptValue(_value); } } contract B { ...
1
vote
1answer
21 views

Return each struct value from a key inside a mapping, where the key is also a value from array inside another mapping

I have a project that I'm working on and I'm trying to figure out a way to do as the title says. I'm looking for the easiest and/or cheapest way(gas wise) and since I'm stuck I'm open to better ways ...
1
vote
1answer
20 views

Listen smart contract event

I use parity --light geth --syncmode "light" I would like to listen smart contract Event. Do I need to download all blockchain on local PC or light mode will be enough?
1
vote
2answers
29 views

Decentralized Exchange on Ethereum?

Is a decentralized exchange basically a smart contract that includes all the exchange functionality? Where is the engine?
1
vote
2answers
49 views

Decode transaction input INSIDE contract with solidity? [duplicate]

I would like to know if it is possible to read blockchain transactions from a smart contract. How web3 has the possibility to scroll, read and decrypt the input data of the transactions, does solidity ...
0
votes
1answer
60 views

Retrieving block hash of current block vs previous block

What is the formula for retrieving the blockhash of 1) previous block and of 2) current block?
0
votes
1answer
19 views

Find word in string solidity

How is it possible to look for if a certain word is part of a string in solidity? let's say someone upload a string to a smart contract, this string must contain the word "solidity" to be accepted by ...
0
votes
2answers
30 views

Solidity how to check if user is already used another contract?

I am trying to figure out how to set up a simple communication between contracts. For example, we have a contract Passport, in which the user writes his data. After that, through the Election ...
0
votes
1answer
30 views

In ICOs why initial supply/total supply tokens are transferred to owner address rather than storing it in the contract itself?

Here I have taken two of the top 20 ERC20 Token/ICO. 1.BNB(https://etherscan.io/address/0xB8c77482e45F1F44dE1745F52C74426C631bDD52#code) 2.BAT(https://etherscan.io/address/...
0
votes
1answer
15 views

Trigger manual DB UPSERTs through smart contract

Can I add a trigger to smart contract to insert/update data to my traditional DB. E.g. Let's say I have students private blockchain where each student has to update their info. Once they insert/update ...
1
vote
2answers
29 views

How to deal with smart contract Versioning

I just got hit by a problem regarding the changes in a smart contract in case of a business use case. Changing the smart contract in general means, " in business terms", loosing the data and starting ...
1
vote
1answer
38 views

overflow/underflow issues?

pragma solidity 0.5.1; contract basics{ using SafeMath for *; uint time; address payable sender; uint amount; event moneySent(address s,uint a); mapping(address=>person) ...
3
votes
1answer
51 views

function input conditional check

I have a function which is accepting a string argument as input parameter. This string is an IPFS hash and I would like to check that the input is actually just that and not a malicious link or the ...