Stack Exchange Network

Stack Exchange network consists of 174 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

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

0
votes
2answers
15 views

Function Payable

I am learning to make a smart contract erc20 can anyone explain what this function means? function () external payable { getTokens(); } function getTokens() payable canDistr public { ...
0
votes
1answer
15 views

Transforming adress into number

i try to transform adresses into numbers to give them strictly different values and class them with order. My operation looks not very interesting and very long. Any idea there ?
0
votes
1answer
13 views

Delete function affects my array in my struct

I am using the function mentioned below to delete a user (i added delete entityList[rowToDelete] to the function )My main issue is that the function deletes the user but somehow I lose the data in ...
2
votes
2answers
23 views

how do you sign transactions programatically?

imagine there's a dapp you're building and on your website users type the receiver address, the value and what you do is send from that user's address to the receiver's address the value ether. My ...
0
votes
1answer
22 views

Can smart contracts make transactions on behalf of the caller?

I want to make a smart contract that wraps over other various smart contracts. In some of these contracts the user needs to send the transaction themselves. Is it possible to make a smart contract ...
0
votes
2answers
18 views

This contract does not implement all functions and thus cannot be created. for myfirstcontract contract Bank is working [on hold]

pragma solidity ^0.4.24; contract Bank { uint private value; function Bank(uint amount) { value = 10; } function deposit(uint amount) { value += amount; } ...
1
vote
0answers
14 views

how to get public key from metamask? [duplicate]

I'm creating a dapp. and I need my users on my website to provide public keys. As I am lazy to write a script which generates public/private keys automatically, I want to suggest an idea that they use ...
0
votes
1answer
29 views

How do i get a smart contract to interact with a website?

I have a site, let's say a user solves a game, i want that user to be stored in a database that represents users who solved the game, users stored in this database will then be able to redeem tokens. ...
0
votes
3answers
28 views

Error when trying to add a payable function in erc20

Most of the ERC20 examples on the internet have this function: // ------------------------------------------------------------------------ // Don't accept ETH // --------------------------------------...
4
votes
2answers
21 views

Block archived event inside blockchain

I want to write a gambling smart contract, that will be based on time (on block number in the ethereum blockchain). What is the best way to do some work when current network block will archive some ...
0
votes
1answer
32 views

Creating an automatically ordered pledge list. Can I do better in terms of gas?

Inspired by What's the best way to return top X values in a mapping? and Are there well-solved and simple storage patterns for Solidity?, I've created a data structure that automatically orders ...
0
votes
1answer
32 views

Return hundreds of arrays efficiently?

I have hundreds, or even thousands of arrays of integers that I'd like to return from a function. I can't return one at a time, because the overhead of making a call to Etherum is too slow in ...
1
vote
2answers
31 views

Handling combinations without recursion

I'm writing a smart contract (in solidity) that has to handle a function that creates arrays of x elements based on one array with n elements. For the purposes of this example, I've experimented with ...
2
votes
0answers
14 views

How does createProxyImpl work in ProxyFactory Contract?

function createProxyImpl(address _target, bytes _data) internal returns (address proxyContract) { assembly { let contractCode := mload(0x40) // Find empty storage location using "...
0
votes
1answer
25 views

pass an array as parameter in solidity

As far as i know solidity doesn't support passing an array of strings into a function ? My issue is that i just added an array of strings (hashs from ipfs) into my struct and i am used to use the ...
0
votes
1answer
21 views

Store N key value pairs

I have a scenario where I need to store N no. of document hashes in a smart contract with some key(id). And also fetch the particular document hash by it's key. Any help on designing the structure for ...
3
votes
2answers
76 views

Delete function in solidity

There is something is wrong with my delete function or i do not know what i have missed. The id of the user is stored in both User (struct) and userIds (array) and i want to be able to delete the id ...
0
votes
0answers
18 views

How to create JSON file for an Rust Contract?

I'm trying to build my own Rust Contract. (I'm referring https://github.com/paritytech/pwasm-tutorial) But Json file is not creating and ABI is not generated. How can I fix this issue? Thanks in ...
3
votes
2answers
41 views

ERC20 transfer reverts when called from one smart contract

I have an ERC20 token MyToken which seems to be working fine. I have another smart contract AirDrop, that is supposed to distribute MyToken. The sendTokens() method takes an array of addresses, and an ...
3
votes
2answers
58 views

Access all the values (tuples) stored in mappings of solidity smart contract using contract address

This question addresses how a value stored in a contract variable from the outside. Is there any similar way to access a value of tuples stored in mapping(with and without knowing a key of mapping). ...
3
votes
1answer
52 views

How do we enable smart contracts on UTXO based chains?

Smart contracts fundamentally enable change of state programmatically. (Is that a fair fundamental description?). How would one go about enabling smart contracts on UTXO based blockchain as against ...
0
votes
1answer
29 views

How can contracts share a whitelist?

I have a token, let's call it TokenA, that inherits from Open Zeppelin Whitelist.sol. TokenB and TokenC both inherit from TokenA and they each have some additional functions. I want all three Tokens ...
2
votes
0answers
27 views

Is returning an array of structs possible yet?

From what I can tell this should be possible now: function test2 () public view returns (Post[]) { Post memory post; post.sender = msg.sender; post.link = "test"; ...
3
votes
1answer
38 views

ERC721 Metadata

Regarding the metadata URI extension - I don't think it should be required that each token ID has an individual metadata URI. I think there should be a globalTokenURI state variable that can be ...
1
vote
1answer
39 views

Smart Contract storage

I was about to create my first smart contract which I came across these questions: Where exactly the contract code gets stored, I read that it kind of stores in blockchain so does that mean every ...
1
vote
1answer
16 views

questions regarding how many bytes each type is

I have questions about how many bytes each type might be. Question 1) now() timestamp. i think it's uint which means uint256 which means 32 bytes? Am I right? Question 2) what does bytes32 mean? ...
1
vote
0answers
25 views

What is the most preferred way to listen to events

After studying about solidity events, my understanding is that receiving an event doesn’t guarantees that the transaction is final. Transaction may yet to be included into the block. And even if it ...
1
vote
2answers
57 views

Solidity smart contract rank system

Is there a common way for ranking system (4 different ranks) in a smart contract? The ranking of a player depends on his ETH spent. The more ETH spent, the higher the rank. This means a player can ...
2
votes
1answer
24 views

Question about require keyword in solidity

Question 1) Let's imagine I have this code require(userVotes[msg.sender] == 0); presidents[_id-1].voteCount++; userVotes[msg.sender] = _id; so If I make a call to this function, and it doesn't pass ...
1
vote
1answer
23 views

mapping for msg.sender doesn't seem to work

state Variable is this : mapping(address=>uint) public userVotes; now i have a function : function votePresident(uint _id) external { presidents[_id-1].voteCount++; userVotes[msg....
1
vote
1answer
23 views

why doesn't it take any gas when making public view function but still writing in storage?

I have four questions. I hope you can help me. Good idea questions, maybe this will help others. Thanks in advance. Question 1) I know that if you don't write anything to storage, then That function ...
1
vote
0answers
18 views

How can I create array of array contains characters with solidity

I recently approached the Smart contract two days ago. I'm still learning about it, and I have a lot of difficulties. Can you help me to create a variable like this photo? It has a arrays of numbers ...
1
vote
1answer
32 views

How to get the address of a contract deployed by another contract?

// deploy a new purchase contract function newPurchase() public payable returns(address newContract) { Purchase c = (new Purchase).value(msg.value)(address(msg.sender)); contracts....
2
votes
2answers
35 views

Why do we distinguish between view and pure?

I understand that the difference is that, while neither may change the state, view may read the state and pure may not. I also understand that it's useful to distinguish possibly state-changing ...
0
votes
1answer
19 views

does it cost gas when executing view or pure function in solidity?

Let's suppose i have the following code in ethereum's solidity function: function getArray() external pure returns(uint[]) { // Instantiate a new array in memory with a length of 3 uint[] memory ...
1
vote
1answer
16 views

ethereum smart contract code question

pragma solidity ^0.4.24; contract MemoryAndStorage { mapping(uint => User) users; struct User{ uint id; uint balance; } function addUser(uint id, uint balance) ...
1
vote
1answer
25 views

Audit request due to paranoia [closed]

I'm paranoid about whether the following contract will work, and the only comments are about where I am paranoid; so, that's where the questions/paranoia really are. This is essentially my one and ...
2
votes
1answer
31 views

Gas Estimation Error when I try to burn token

pragma solidity ^0.4.18; /** * @title SafeMath * @dev Math operations with safety checks that throw on error */ library SafeMath { /** * @dev Multiplies two numbers, throws on overflow. ...
0
votes
1answer
19 views

In up gradable design pattern how to set the allowed contracts or owner during deployment of smart contracts

Functional Background: Contracts for upgradable design pattern: ProofDB.sol : contract to store the data. Proof.sol : contract that contains the business logic. Registry.sol: contract that ...
0
votes
1answer
32 views

Why wouldn't it be good to store lots of data in ethereum logs instead of smart contract?

I'm curious where to save big data. I don't want to save it in my private db and not in ipfs. I want it to be visible on blockchain. So It's visible on blockchain etherscan If I'd go to store data in ...
1
vote
2answers
39 views

Where are finally ethereum event logs stored?

Hello it's been written many times, but as I observe none of the answers might be the one. I'm interested in the following thing. If in a smart contract I made the event , where will it be stored? in ...
3
votes
1answer
17 views

Contract design by contract -> correctness and maximum gas consumption

This question is a general design question that regards contract correctness and the functions I list here are just examples. As I develop on Ethereum, it becomes aparent to me that it might be ...
1
vote
0answers
26 views

How to save big data on ethereum smart contracts [duplicate]

It's been some time since I started figuring this out. I'd really appreciate your ideas and opinions. I'm building an app on ethereum smart contract. But the thing is There might be so huge big data. ...
1
vote
1answer
13 views

Access manager in Smart Contract

I'm building a service where one can publish a crypted file on the internet which can be accessed and decrypted by people allowed. I don't want to store any crypted key on a server or something. For ...
0
votes
2answers
31 views

Solidity Checks-Effects-Interactions Pattern

From the solidity docs: Use the Checks-Effects-Interactions Pattern Most functions will first perform some checks (who called the function, are the arguments in range, did they send enough Ether, ...
1
vote
1answer
17 views

Filter topic across multiple contracts

Is there something I could add to my contract which allows my application to filter for all the deployed contracts which also included this topic/identifier? The only other option to manage this I ...
1
vote
0answers
34 views

How do we deploy a smart contract with Oraclize to Rinkeby Network?

I have created a smart contract with Oraclize logic which I tested locally using Truffle. Now I want to test it on Rinkeby network along with my front end, what it the process to do so ? How do we ...
2
votes
1answer
38 views

Apart from array and mapping Is there anyway to store large number of user information in Ethereum blockcain?

I have a smart contract to store user information in Ethereum blockchain. For every new transaction entry gets added into map or array. This looks too costly in terms of storage. If I use map or array ...
0
votes
0answers
21 views

How to identify Gas Needed to successfully execute a Smart Contract with Oraclize Callback

I have created below smart contract for a Proof of Existence project. It receives few inputs in 'createProof' function which are timestamped using Oraclize Services inside '__callback' and '...
1
vote
0answers
22 views

How to pre-compute Gas requirement of a function to avoid metamask error

How can we pre-compute Gas needed for successful execution of a function inside a smart contract. I got to know about web3.eth.estimateGas but cannot follow it completely from the docs. My function ...