Questions tagged [contract-development]

Questions regarding the development of smart contracts

Filter by
Sorted by
Tagged with
0
votes
1answer
17 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
25 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
21 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
31 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
17 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
30 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
29 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
29 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 ...
0
votes
1answer
27 views

Auto-Response smart contract

I would like to make a smart contract that can auto-respond.. Something like an email auto-responder. A user sends a transaction with a message to the smart contract, and if that message is ' True' , ...
1
vote
1answer
31 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
16 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
21 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
11 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
13 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
14 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
37 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
38 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
23 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 { ...
-1
votes
1answer
28 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
27 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
22 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
19 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
17 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
29 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
48 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
19 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
41 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
26 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
20 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 ...
0
votes
0answers
23 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
17 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
11 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
30 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
20 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
18 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
88 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
16 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)...
1
vote
2answers
22 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
20 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
69 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 ...
0
votes
1answer
16 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
26 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
37 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
19 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
18 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
33 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
27 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
18 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 ...