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
0answers
13 views

when to use byte32 -> string conversion in events, functions etc

When is it a good practice to use string conversion from bytes32? i.e. in events, functions and similar. What does doing so bring in terms of cons to gas costs?
2
votes
0answers
21 views

Name Styling Best Practices Internal/External variables/functions etc

The solidity docs clearly specify how to style function order, types etc. However, are there an appropriate way to also separate between internal/external variables, functions etc. I see some people ...
0
votes
2answers
26 views

Fetching stored values for use in function logic

Are there any benefits from fetching stored data into other functions by calling a function to call a private variable, instead of calling the private variable directly? What is best practices? ...
0
votes
1answer
16 views

Get a list of tokens inside an ethereum wallet address

is there a way(mostly a api) to get all the tokens currently being held by a wallet address?(Their contract addresses)
0
votes
1answer
45 views

create ERC-20 token from a contract function

I would like to do a function create contract with ERC-20 interface. But I have a few problems. If anyone help me I’ll be appreciated. Here’s the code : pragma solidity ^0.5.0; import 'https://...
1
vote
2answers
46 views

How to get transaction status (programatically, not etherscan)?

I have a problem when I interact with an Smart Contract, from a javascript webapp. I can execute the transaction correctly when the status is confirmed, but I cannot get any error response when it ...
0
votes
1answer
32 views

create contract from function / contract

**Hey guys ! I just try to make a contract for create a contract. It supposed to be ERC-20 interface so my first contract for this. But I don’t know how can I do _mint and createContract functions ...
0
votes
1answer
26 views

uint[] to address with correct checksum

Lets say we have something like this as a given: bytes20 b = bytes20(someAddress); uint8[] memory array = new uint8[](b.length); for (uint256 n = 0; n < b.length; n++) { array[n] = uint8(uint160(...
1
vote
2answers
35 views

Who is msg.sender in a nested call chain?

I read about who is msg.sender when calling a contract from a contract, but who is msg.sender when calling a contract from a contract that calls another contract and so on and so forth?
0
votes
1answer
23 views

Adding the delta to a token transfer

Let's say I have 5 contributors to a pool of a smart contract. They all contributed 1 ether. The smart contract lost 2 ether, and now I want to transfer back the remaining 3 ether to the 5 ...
0
votes
1answer
23 views

Expected identifier but got reserved keyword 'reference' Product public reference; ^-------^ [closed]

hello guys I am a beginner. I would like to make a function for create a contract. I found a example on the internet but gives me an error so I dont know what should I do. Anyone can help me ? ...
0
votes
1answer
19 views

Tallying Majority Consensus From Nested Struct

How do I tally the votes of a nested struct to find out majority consensus? as an example, if we have following scenario below; I want to create a function which allows me to calculate whether ...
0
votes
0answers
26 views

Interaction smart contract and third-party app : How to make sure the request comes from the original contract?

I'm working on a blockchain project where I need to access data stored outside the smart contract. The smart contract own a RSA keypair (one public and one private key). We want the private key to ...
0
votes
1answer
27 views

Initialising Empty Arrays & Structs In Struct-based Storage Graph Structures?

How do I initialise empty arrays and structs in nested structs data structures? contract NewBook { struct ReviewerData { string name, uint industryXP // ...
1
vote
1answer
39 views

Updating an instance of an already stored struct?

How can I update/change the values of a stored struct instance? as an example: Let's say I've already deployed a chapter with the content written in a particular color. Later it turns out that I ...
0
votes
1answer
20 views

Returning an array of inner structs of a struct

How can I return an array of child structs of a parent struct? as an example: After pushing multiple chapters into the parent struct, how can I retrieve all the child structs as an array (or ...
0
votes
1answer
34 views

contract reading array from other contract

There are two contracts in my project: admin groups voting Admin groups contain mapping(uint => address[]) internal m_Admins For example [1][0] = admin #1 with level 1 [9][0] = admin #2 with ...
0
votes
1answer
32 views

Pushing A Struct Instance Into An Struct Array Of A Different Struct Mapping

How can I push a struct instance into a mapping which contains a distinct struct which contains a struct array of the attempted struct instance type? Example: contract NewBook { struct ...
0
votes
1answer
58 views

Mapping Multiple Struct Instances To One Address

How can I map multiple struct instances to one user without overriding the previous instance? I want to retrieve both instances through one mapping query. Should I use a multi-dimensional array here ...
1
vote
1answer
34 views

Random Group Generation From Array

How can I form a random group of 5 people from an array of 100 people?
1
vote
1answer
23 views

Does the 10,000 refund apply to booleans too?

I understand from this thread that you're refunded up to 10,000 gas when setting a value to 0. Does this also apply to boolean values? That is, going from true to false?
0
votes
2answers
23 views

Smart Contract Interfacing - Best Practices

what is a general rule of thumb for creating interfaces? Why would I want an interface i.e. IAugur.sol instead of the entire Augur.sol file? Can someone shed light on interface best practices and pros/...
0
votes
1answer
13 views

What would web3.js respond with in this case?

I have a mapping to a struct in my contract mapping (uint=> Student) students; struct Student { bool passed; } Now I want to call a particular student with a particular ID to see if he has ...
0
votes
1answer
32 views

Commit-Reveal Sequence Design

Let's cook up a scenario to ease understanding: We have a group of 5 people (addresses) who must vote on a question. The people can only vote True or False i.e. a boolean. The result of the vote ...
0
votes
0answers
20 views

web3j - getter for array of addresses

I have a contract which has a field registry which is an array of addresses, Also have a getter for this field: function getRegistry() view public returns (address[] memory){ return ...
0
votes
1answer
58 views

explanation of appending .selector in solidity smart contracts

I'm trying to understand what .selector means when appended to logic wrapped up inside of functions definitions. I've tried to read the section in soliditydocs, but it doesn't seem to answer my ...
2
votes
1answer
56 views

Convert address to string after solidity 0.5.x

After solidity 0.5.x release none of conversions from address to string appear to be working. I've tested all of them on remix and got errors like converting bytes to uint or something like this. ...
0
votes
1answer
58 views

How to use function modifier to control contract function access right?

I deployed a ERC20Mintable token in truffle environment(the source file is ERC20Mintable.sol). The mint function is declared with onlyMinter modifer: contract ERC20Mintable is ERC20, MinterRole { ...
0
votes
1answer
59 views

Logical OR operator is not working in IF condition, solidity 0.5.0

I wanted to ask if is it available to use OR operator in IF conditions, because its giving me awkward results, like this: contract test { if(player1Points > Player2Points || player1Points >= ...
0
votes
1answer
40 views

Solidity returns “ParserError: Expected primary expression” on my code below, can anyone help?

pragma solidity ^0.5.8; //Change the contract name to your token name contract JONJonnywon { // Name your custom token string public constant name = "JONNYWON"; // Name your custom token ...
2
votes
1answer
30 views

Ethereum Blockchain Interoperability

I was reading through Vitalik's blockchain interoperability paper available here One thing he mentions is a company / project called EthereumLottery.io (currently not operating) which managed to ...
1
vote
1answer
138 views

Explicit type conversion not allowed from “bytes1” to “uint256”

Just tried to convert byte to uint using Solidity 0.5.x: uint length = uint(arr[i]); and got: MyCode.sol:88:29: TypeError: Explicit type conversion not allowed from "bytes1" to "uint256". ...
1
vote
1answer
28 views

Using contract to create Child contracts (web3j Java wrapper)

I have a simple Parent contract that creates child contracts and stores their address. contract Parent { address[] public registry; function createChild () public { address newChild =...
0
votes
1answer
42 views

Contract function call error “TypeError: Cannot read property 'isMinter' of undefined” using Truffle tool

I deployed a ERC20Mintable token in truffle env(the .sol file is ERC20Mintable.sol). 2_mintable.js ============= Deploying 'ERC20Mintable' ------------------------- > transaction hash: ...
0
votes
1answer
84 views

'types/values length mismatch',

Hey guys I had a problem with my return function here's my smart contract : pragma solidity >=0.4.0 <0.7.0; contract NewHello{ address owner; address newOwner; constructor()public{ ...
0
votes
1answer
37 views

How can one user(Patient) can share information to other user in solidity

I am looking to Design Smart Contract using Ethereum Blockchain for storing and retrieving Medical Recoreds in Blockchain. As I am new to Ethereum I am little issue with below thing. anyone have any ...
1
vote
1answer
48 views

Which is faster: loop inside contract or loop of transactions?

I have this contract: pragma solidity 0.5; pragma experimental ABIEncoderV2; contract TestStruct { struct User { string name; uint256 age; } mapping (bytes32 => ...
0
votes
2answers
32 views

How can I pack two int16 into a single byte32?

I have a contract that makes use of cartesian coordinates. My initial thought is to map a single location (x,y) to a value/struct. I would like to define any given pair of coordinates by a single ...
2
votes
1answer
94 views

Status of ABIEncoderV2 now

Do you know the current status of ABIEncoderV2? I want to know the current status of ABIEncoderV2 Live projects using ABIEncoderV2 right now Restriction on the normal encoder Risks of using ...
1
vote
2answers
35 views

Contract.deployed() does not work as expected

I use Truffle to test a contract. When i use Contract.deployed() and i fetch address, for example : In a first test, the contract's address is 0x07D899846146b3503dE9D9Dc36B94C2e428eA434 In a second ...
0
votes
1answer
18 views

Scaling a 'factory' design approach when listing contracts

I am building a smart contract that uses a factory contract to deploy a new sub-contract (example some campaign). This campaign has a boolean flag isActive. Every time the factory deploys a campaign, ...
1
vote
1answer
16 views

Gas cost for contract transaction called form external

If I call my contract and ask it to send x amount of ether to another account y, I know i have to pay a transaction cost. Will the contract also have to pay any amount while sending the ether to the ...
0
votes
1answer
33 views

How event in ethereum actually works?

I'm currently working with Ethereum and smart contracts. I see that a contract can define events and emit them. Each event defines no target, so I assume it will be broadcast. But I wonder how to ...
0
votes
1answer
21 views

Is Smart Contract of any ERC20 token is always available publicly

Is Smart Contract of any ERC20 token is always available publicly. If not complete, then what things are generally available,(for eg, except some sensitive information) And, if not any of them are ...
0
votes
0answers
23 views

storing ERC20 inside of Non-fungible tokens?

Is it possible to store value in the form of ERC-20 tokens inside of non-fungible tokens such as ERC-721? If so, could someone showcase how through an example?
2
votes
2answers
148 views

Syntax Error: Type tuple(bool,bytes memory) is not implicitly convertible to expected type bool

I am trying to compile the following program: pragma solidity ^0.5.1; contract MKotET1_1{ address payable king; uint public claimPrice = 100; function calculateCompensation() public ...
1
vote
1answer
21 views

call: Warning: Unused local variable

I am trying to compile the following code: pragma solidity ^0.5.1; contract MKotET1_1{ address payable king; uint public claimPrice = 100; function calculateCompensation() public returns(uint)...
2
votes
2answers
49 views

To transfer tokens from owner address to an address, if latter address moves some other tokens to a given particular address

I am writing a contract for an ERC20 token (say ABC). Is it possible to airdrop some of these newly minted ABC tokens to those ERC20 addresses, every time, if they transfer a different token (named ...
0
votes
1answer
21 views

watch event for each iteration in forloop - Contract Function

I have a contract function in private network with a for loop and emitting event inside the loop. Following is the code : pragma solidity ^0.4.20; contract Eventsloop{ event loopidx(uint idx,uint ...
1
vote
1answer
81 views

How to call a contract function that alters blockchain state on geth console

It should be easy, but I'm having a hard time using a simple smart contract described in the Solidity language reference called SimpleStorage. It only as one attribute, a setter and a getter, and I'm ...