The Stack Overflow podcast is back! Listen to an interview with our new CEO.

Questions tagged [contract-development]

Questions regarding the development of smart contracts

Filter by
Sorted by
Tagged with
0
votes
1answer
18 views

Syntax Error & how pay( ) would execute without explicitly calling pay( )?

I am getting a syntax error in the following code: pragma solidity ^0.5.1; contract C { function pay(uint n, address payable d)public { d.send(n); } } contract D1 { uint ...
0
votes
2answers
32 views

Effective way to compare to arrays

What is the most cost effective way to compare to arrays eg. uint arrays in solidity. Running a for loop takes too much gas.
0
votes
2answers
61 views

Instantiating a contract inside another contract on behalf of some address

I want to initialise an instance of a contract inside another contract on behalf of some address. e.g. I have contracts A and B contract A{ address owner; constructor() public{ ...
0
votes
1answer
22 views

Calling function of another contract in constructor not working anymore

I have a contract ElectionMaster that contains an array with all elections available in the network. When I create a new Election it calls a function addElection from ElectionMaster and registers ...
0
votes
1answer
20 views

Problem understanding the owner assignment

Suppose I have 3 contracts, namely Owner, B and C: contract Owned { address public owner; constructor() public { owner = msg.sender; } modifier onlyOwner { require(...
0
votes
1answer
17 views

Contract Function calling storage contract not setting value correctly

so i have a storage Contract A which has the following mapping and function. mapping (address => mapping (bytes32 => uint8)) addressToQueryIDToStatus; // 0=no init, 1=init, 2=fail, 3=succeed, ...
0
votes
2answers
54 views

Why should I use an ERC-721 token to store data instead of a Smart Contract

Taking CryptoKitties as example, I'm sure it's possible to achieve the same concept of Crypto Collectable creating new kitties as Smart Contracts instead of using Tokens. Which would be the ...
0
votes
0answers
33 views

Truffle migration contract [duplicate]

Why do we have to deploy the migration solidity contract in truffle? Do we also have to deploy it during production? Why do we have to deploy it so many times and why can't we use a single large ...
3
votes
1answer
33 views

Documenting Smart Contracts and Dapps - community standards and tools

Do you guys know of any kind of documentation standards that are widely used within the Ethereum community? Any kind of documentation tools will also be of great help. Thanks in advance.
1
vote
0answers
21 views

Why after managing to deploy contract to POA Ethereum blockchain I can't interact with it? [duplicate]

We are using a private ETH proof of authority blockchain. In order to deploy a contract I'm using 0 gas price and it deployed immediately. Then, Tried to deploy many types of contracts with ...
2
votes
0answers
58 views

How the following pairing equality be verified in Etherum Smart contracts?

I have found available precompiled contracts in solidity. For example, this answer enter link description here points out a precompiled contract that can verify BLS signature. However, looking to the ...
2
votes
1answer
84 views

After EIP 198 introduction, how much gas is required for RSA signature verification in solidity?

Thanks to the introduction of EIP 198, RSA signature verification is now feasible in Ethereum. How much gas is required for such a verification?
3
votes
1answer
60 views

Compilation error using SafeMath

I am trying to do subtraction operation using the SafeMath library. The following is my code: pragma solidity ^0.5.1; library SafeMath { function sub(uint256 a, uint256 b) internal pure returns (...
1
vote
2answers
55 views

Storage/Retrieval of mapped structure data

I want to store the structure data in a mapping i.e. if I have a student structure as described below, then I should be able to have a myriad of students and distinguish between them using wallet ...
0
votes
1answer
49 views

Why do my events not emit the correct value?

When testing a contract with Truffle, I have found that the variables that are emitted by the event do not match the values that are passed into the event emission. Why does the event not return the ...
0
votes
1answer
88 views

How to test the fuctionality of a Bittrex-related smart contract?

I've got my hands on a smart contract related to the Bittrex exchange. I would like to deploy this smart contract to test the functionality but I don't know how to call the functions properly. My ...
3
votes
1answer
52 views

Matrix multiplication in solidity

I am trying to implement an algorithm requiring matrix multiplication. I know I can program this in the rudimentary way similar to doing the process by hand, but I am worried about the computational ...
2
votes
1answer
71 views

Errors in when compiling the BLS signature in remix?

Etherum can verify BLS signatures, In this answer Does Ethereum support pairing operations? There is an example of how to verify BLS in solidity. However, when I tried to test the code in remix, ...
0
votes
2answers
30 views

What's happening if my variable on smart contract arrives at your limit? and what's the best practice to treat this? [duplicate]

I have one variable on a smart contract called count, every function call, i put one more value on her. count++; What's happening if my variable on smart contract arrives at your limit? 2^256 -1 ? ...
3
votes
2answers
202 views

Verifying Modular exponentiation operation in etherum

I have Alice who should do some cryptographic operations off-chain. Then a smart contact has to verify equality by performing Modular exponentiation operation. I attached an image of the off-chain ...
1
vote
1answer
113 views

Updating ERC20 Contract from 0.4.0 to 0.6.0

Im updating some ERC20 contact code from solidity 0.4.0 to 0.6.0 and hitting some snags as it seems openzeppeling has changed its structure since then as can be expected. I cant access the balances ...
0
votes
1answer
226 views

Web3 Contract.balanceOf is not a function

I have read this helpful SO answer about sending ERC20 contracts, but it seems that the Web3 docs and API have changed dramatically since then. I am trying to get the balance of a smart contract using ...
0
votes
1answer
38 views

Can't import a contract interface in vyper

I need to import a contract interface using the JSON ABI but I get syntax error when trying to import the interface. I have created the JSON file in remix and named it IERC1620.json then I am trying ...
1
vote
1answer
29 views

Update Private Ethereum node

Now suppose I created my private blockchain using ethereum over any cloud, created dapps over it and created my own crypto over that. Now if ethereum update consensus to POS from POW I want my private ...
1
vote
1answer
54 views

How to create a variable in storage via the solidity assembler

Similar to this question How to get access to the storage array through the solidity assembler? But instead of accessing a storage variable, I want to create a new storage variable via assembly. That ...
0
votes
2answers
43 views

How to dynamically generate a variable without declaring it in a contract (solidity)

Is it possible to generate a non-local variable with a function? Weird question but it's for an exercise my senior asked me to do, I've scoured the web for an answer to no avail. Instead of ...
1
vote
1answer
22 views

Why does a mapping update itself when I am not doing anything?

The title is a little bit vague but I've seen this contract and tried it on remix: pragma solidity ^0.4.24; contract Tester { struct Account { uint256 balance; } mapping (address => ...
1
vote
1answer
50 views

How to declare a storage variable in vyper?

I am trying to convert my solidity code into vyper but I can't find a way to declare a storage variable. My solidity function was this: struct Account { uint256 balance; // Account's balance uint256 ...
1
vote
1answer
36 views

Strict Balance Equality (Security Issue)

Research Paper, Page-5(Strict Balance Equality)I have read that attacker can use Selfdestruct() and forcibly send ethers to the contracts. My questions are: If Selfdestruct is meant for owner of ...
2
votes
1answer
51 views

why a parameter must be “storage” or “memory”?

I am creating a token like this: pragma solidity ^0.5.0; import "../utils/math/SafeMath.sol"; contract ExampleDivisibleNFTs { using SafeMath for uint256; // Percentage of ownership over a ...
0
votes
2answers
65 views

Public key validation through private key

What is a good way to validate that the public key claimed to belong to a particular user really belongs to him without revealing the associated private key? Can this be done with zero-knowledge ...
0
votes
3answers
77 views

mapping one id to multiple addresses

Suppose I have a product with a specific id for sale(so I am the owner) and someone wants to buy the product from me. When he pays the price he will become the new owner of that product. How can I ...
0
votes
1answer
23 views

Storing geo location in contract

I am beginner in solidity programming, I am trying to write my first contract. I am trying to store a piece of land (which is array of coordinates) against a person. I am having trouble storing the ...
1
vote
2answers
41 views

How does the contract TwitterHumanityApplicant queries the Twitter API?

TwitterHumanityApplicant is (as I understand) a smart contract that validates that a human (or a Twitter user) owns a wallet. I was expecting to see in the contract code something that resembles a ...
0
votes
0answers
26 views

Monetizing my dApp

I'm working on a project that will allow users to use our platform to auction stuff. Programatically, how would I convert this idea into a profit for me. I want to take a 3.75% fee from any won ...
0
votes
1answer
25 views

truffle won't run tests while initializing a global contract instance

I am testing my smart contract in truffle. I need to declare some global variables hence I did so outside 'it'. I also tried declaring a global contract instance that I can use in all test cases. ...
2
votes
2answers
62 views

Splitting and Merging tokens

i'm here to ask if my project is doable or not. I'm actually reading "Mastering Ethereum" by Andreas M. Antonopoulos, so i have some basic solidity knowledge. I have a project: I have a building, ...
0
votes
0answers
26 views

how much structure variable does solidity support? [duplicate]

Error: "UnimplementedFeatureError: Variable inaccessible, too deep inside stack" code: contract create{ struct s{ string s1; string s2; string s3; string s4; ...
0
votes
0answers
37 views

Anything like a static delegatecall from a view function?

let's say there are two contracts A and B, where A calls methods in B. I understand that A can modify and read storage in B with B.call() and B.staticcall(), ie. A can execute B's methods in the ...
0
votes
0answers
295 views

Web3 Cannot read property 'apply' of undefined

I'm new to dapp and trying to follow iwaldman to build an ipfs-image-dapp. Here is the repo: https://github.com/iwaldman/ipfs-image-dapp. But running yarn start gives the error Cannot read property '...
0
votes
0answers
21 views

Change params from another contract

Is it possible to change params of one contract from another? I mean: contract One { address public addr; } contract Two { function test(address oneAdd) public { One one = One(oneAdd); ...
4
votes
3answers
274 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 ...
1
vote
1answer
36 views

How to increase the number of test accounts?

I have encountered a problem where I need a large number of test accounts. How can I increase the number of test accounts from 10. Remix and ganache only give 10 accounts. I require more than that.
1
vote
1answer
19 views

Return fees - is it save?

I would like to return partially fees to users of my dApp. Once they have reached X amount in fees, I want to make a function that will pay them ethereum automatically. Now my question: Is that secure?...
0
votes
1answer
33 views

Multiply small rational number to obtain integer piece

I'm trying to make some advanced calculations in Solidity. I was able to successfully implement the algorithm on my contract, but its results are way below zero, and whenever I try to get it with ...
2
votes
1answer
106 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
44 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
43 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 ...
0
votes
2answers
28 views

How to find out if a wallet (an address) contains a token from a contract using web3js?

Is this possible with and without knowing the private key of the wallet.
0
votes
1answer
18 views

Fallback function optimization: what better?

I have ERC20 contract with payable function. 1 function () external payable { uint256 amount = msg.value * unitsOneEthCanBuy / 1000000000000; balances[msg.sender] +=amount; balances[...