All Questions

0
votes
1answer
33 views

Random number generation in certain range

I need to add a random number function in my smart contract. Is it best to use Oraclize and e.g. random.org? It's not a lottery which means the random number generation does not require heavy security....
0
votes
2answers
36 views

How to access content of mapping in a struct?

I'm aware of this post: Accessing a mapping within a struct via Truffle console However, it seems to me, it does not provide a clear answer. Also, my question is more generic and not just for ...
0
votes
2answers
14 views

Transaction Ordering doubt for msg.sender.balance

I searched for SE and google, but did not find answer to this simple doubt. If I include two transactions (state changing ones which cost gas) in same block for execution. Then my question is: will ...
1
vote
0answers
20 views

How to use web3-react with truffle Dapp? any sample code / tutorial?

I am new to react and finding issues with the front-end of the Dapp application. Especially in web3 version > web3 1.0.0 I just heard about the web3-react and I think it will be a lot easier. I ...
1
vote
1answer
30 views

where does the metamask fits in Dapps architecture?

i am learning building Dapps. And i got to know to know about metamask. I've read about metamask is an ethereum wallet which we can use to sign Tx's without running a full node and inject web3 to ...
0
votes
0answers
18 views

web3.eth.getBlock in order

I am a beginner for Javascript & web3(0.20). I am using Metamask for watching allevents, and I need to get timestamp. I use getBlock.timestamp. Due to Javascript, timestamps are not inorder. I ...
0
votes
1answer
25 views

How to withdraw from multiple contracts?

Thank you for watching this topic. I'm not sure how I can withdraw my balance from multiple contracts. The situation is like this. 1)People have rights to withdraw each fund. 2)funds are stored at ...
0
votes
0answers
21 views

Auction contract privacy

I have an auction contract, where bidders bid with Ether then me (owner) select which offer is most suitable and thus this bidder is contract winner. Once the winner is selected, I send him data as a ...
0
votes
1answer
21 views

My Withdraw function doesnt work

I'm writing my first contract and my withdraw function doesnt work. Eth doesnt move to my _withdrawAddr. Also can somebody explain why my function getBalanceThis returns 0 instead of amount I send to ...
0
votes
0answers
18 views

Instantiation of an EVM on goLang

I'm dealing with goLang on an go-ethereum fork. In order to query a contract endpoint I need to get a fresh EVM reference for properly call the contract. I've found there is a NewEVM function that ...
0
votes
1answer
20 views

Object to Hex function (like in sign transaction)

I am reading the Web3 documentation about signing transactions (see example below). As I understand it, the "transaction object" gets turned into a hex string and enveloped, this is the "message". The ...
0
votes
0answers
10 views

POA ethereum Add Authority Account Contract

Can someone point me right tutorial to understand the following 1) Genesis configuration for POA with pre-fund account 2) How to add Authority account at run time means once the blockchain is up ...
0
votes
2answers
17 views

Different events for revert types or one event and then on the client/backend figure the reason why it reverted from emitted data?

Let's say I have 3 conditions which can lead to revert(). which way should I handle it? 3 types of events or one event with extra parameters? 3 events types: if condition A: emit causeA(dataA1, ...
0
votes
1answer
15 views

Parser Error - Creating EIP20 Tokens

function transfer(address _to, uint256 _value) public returns (bool success) { require(balances[msg.sender] >= _value); balances[msg.sender] -= _value; balances[_to] += _value; emit ...
0
votes
1answer
9 views

Contracts interaction issue

I got stuck in making two contracts interact. The code for two contracts is as follows: Test1.sol pragma solidity ^0.5.8; contract Test1 { struct Car { string carCreationDate; ...
0
votes
1answer
17 views

Parity POA Smart Contract Method Always Fails

I have set up a private POA Network according to the tutorial from the parity homepage. I have two nodes running on localhost:8540 and localhost:8541. I have connected MetaMask to my first node and am ...
0
votes
1answer
28 views

Can anyone explain How smart contract gets validated?

Is there any validation process of smart contract's write operations ?
1
vote
1answer
30 views

Is there any way to only find blocks where state changes of a contract occurred?

I'm currently using the ethereumjs libraries (https://github.com/ethereumjs) to iterate over the blockchain, replay transactions and read the state trie of a contract from the geth leveldb. Currently ...
0
votes
1answer
27 views

How do I change the consensus algorithm for a network that i forked from github? [closed]

can i change the consensus algorithm for a network that has forked from github? is there any link to understand how can make changes to consensus
0
votes
0answers
14 views

solcx compile_files Key error

I am using python package py-solc-x for compiling the smart contract. os.path.abspath("D:/new.sol") Gives path where my test contract exits. 'D:\\new.sol' Then i use compile_files to compile the ...
1
vote
1answer
19 views

Block Gas Limit Doubt

Suppose i have a loop. Here user is a struct of which player is an address. address[] memory addrs = new address[](n); for(uint i=0;i<n;i++){ addrs[i] = user.player; } return addrs; This is a ...
0
votes
1answer
43 views

How to hash multiple values including array keccak256 Solidity v5.0.x and web3 'Autodetection of array types is not supported.'

How can I receive the same hash in solidity and web3? Multiple values where one is a multi dimensional array. Solidity v0.5.x: pragma solidity 0.5.6; pragma experimental ABIEncoderV2; contract Hash{...
1
vote
3answers
29 views

Verify if an input is a hash

What is the best way to verify that a text I received in mu function is a valid hash? In other words, contains a specified length and is composed only by numbers and "a", "b", "c", "d", "e" or "f"?
0
votes
1answer
15 views

Gas requirement of function “testCompile.showString() high: infinite”

I have written simple function in remix. pragma solidity ^0.5.0; contract testCompile{ string myString = "Hello World"; function showString() public view returns (string memory){...
0
votes
0answers
39 views

Timestamp is giving wrong time in smart contract

Today is June 17. but when I execute my function and store the following arguments. WriterModel(owner,postID, _postContent, now); "now", It returns the July 20 timestamp. It perfectly working fine ...
0
votes
0answers
29 views

Web3 in the browser

Importing web3@1.0.0-beta.55 in a stencil+typescript file for a frontend application directly triggers an error, even without using the imported Web3 object whatsoever. import Web3 from 'web3'; -> ...
1
vote
0answers
18 views

What do I do to deploy my ERC 20 token [closed]

I have a ERC 20 token platform the token: BTZ botztoken and what I am wanting to do is figure out what I can do with the tokens as utility tokens to accomplish teams mission which is: to help ...
0
votes
0answers
21 views

Is there any API for ether sent transaction in ethereum without using web3.js [closed]

I want to do a transaction (sent ether or token) by API, not from web3.js I have tried etherscan, block cypher This is a get balance API code like this I want send transaction code ...
0
votes
0answers
21 views

Function returns always with the same input even it is in the loop..TRUFFLE+ANGULAR 7+WEB3

One of the function in Contract: function getPostCounts(uint _postID)public view returns(PostCountsModel memory postCounts){ return postCountOperations[_postID]; } This is the calling ...
-2
votes
2answers
17 views

Can't seem to find MetaMask

I've opened Chrome extension and downloaded the Brave search engine. However, even though I've selected to show MetaMask in my tool bar it's not showing anywhere and I don't know how to access it. So, ...
1
vote
0answers
36 views

exploiting keccak for random number generation?

Whenever a ticket will be purchased, a random number will be generated function _mightWin() internal { address _player = msg.sender; // players address uint256 ...
0
votes
1answer
45 views

Percentage calculation

I'm currently learning how to write smart contracts. While studying some code, I came across this line: ‭ uint256 a = value.ceil(basePercent); (with: uint256 public basePercent = 100;) Then one ...
0
votes
1answer
27 views

Value not pushing into array inside structure

pragma solidity ^0.5.0; contract Testing{ struct personalInfo { uint id; string[] colors; bool player; } mapping(uint=> ...
1
vote
0answers
21 views

How to upgrade this Crowdsale contract (from DappUniverse)

i'm trying to compile this code (from DappUniversity: https://github.com/dappuniversity/ico_irl/blob/master/contracts/DappTokenCrowdsale.sol) but with the new version of OpenZeppelin, that's use at ...
0
votes
1answer
13 views

Can I pass my mnemonic to ganache/ ganache-cli when it is starting up?

I am wondering if I can pass the mnemonic that I created using metamask to boot up my local ganache network so that I do not have to log out and login metamask with different mnemonic everytime for a ...
1
vote
1answer
44 views

Mapping with iterating uint as identifier - multiple transactions in the same block

I want to use an iterating uint as an identifying number, but I have a simple question to make sure I can do this safely on the mainnet. Here's a simple example to demonstrate the issue: pragma ...
0
votes
0answers
18 views

web3js batch execute method gives error

I have private/local network/chain setup. I'm building this with Nodejs-->expressjs. const contract = new web3.eth.Contract(abi, address); const batch = new web3.BatchRequest(); batch.add(contract....
1
vote
0answers
16 views

How to process null TransactionReceipt?

I have some transaction that is sent and from time to time when I call the eth_getTransactionReceipt I get a null. I see esentially two approaches for handling this: I could reiterate the call to ...
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
32 views

Save all customers who buy an item online [closed]

I am writing a contract where I am trying to save the account addresses of customers who buy an item online. I tried it with arrays but it did not work. Can anyone please suggest a way of doing this?
0
votes
0answers
13 views

Is there a way to import bulk private keys in geth or any other offline wallet?

I am running a test which involves creating several thousand ethereum wallets. Is there any way to import the private keys of these wallets in bulk in geth or any other offline wallet?
0
votes
1answer
63 views

TRUFFE MIGRATE: Saving migration to chain.Error: Error: Error: Returned error: VM Exception while processing transaction: invalid opcode

$ truffle migrate Compiling your contracts... =========================== > Everything is up to date, there is nothing to compile. Starting migrations... ====================== > Network name: ...
0
votes
1answer
21 views

ERC20, how to calculate how many tokens for crowdsale?

If you look at this article, the total tokens for crowdsale is 100 tokens and defined in the code as uint256 public maxTokens = 100000000000000000000; how come 100000000000000000000 becomes 100 ...
0
votes
2answers
33 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
2answers
13 views

ParserError: Expected identifier but got 'address'

I am trying to execute the following code: pragma solidity ^0.5.1; contract contractA { function blah(int x, int y) public payable {} } contract contractB { function invokeContractA() { ...
0
votes
0answers
23 views

problem with the task function in truffle development

I am doing the "TodoList" exercise and when I use truffle (development), I do not return the call with task, I get the following error: truffle (development)> todoList = await TodoList.deployed () ...
0
votes
1answer
14 views

Code A Contract To Accept A Different Token (Other Than ETH)

I'm developing a DApp for Decentraland that will accept payments in their ERC-20 token MANA. How can I code a smart contract to accept a token other than Eth? How can msg.value know the value of a ...
-2
votes
0answers
33 views

Gas Cost Within a Loop? Infinite With/Without State Variables: Local Var Does Not Dec Cost

I found that state variables should be optimized at: Frequently Asked Questions Note2: Optimizing storage access can pull the gas costs down considerably. I am using a state variable in a loop for ...
0
votes
0answers
19 views

How to import account of metamask in js? [closed]

ethWeb3.eth.getAccounts((error, accounts) => { console.log(accounts[0]); $('#currentAcntDisplayID').text(accounts[0]); ethWeb3.eth.defaultAccount = ...
0
votes
1answer
19 views

Function to transfer tokens to a second address with fixed percentage

I'm trying to code a transfer function that automatically sends tokens to a second address taking a specific percentage from the original sent value. What I wrote: address public _ExtAddress; ...

15 30 50 per page