texts: Obtaining list of all addresses having sent money to a specific adress inside a Solidity contract

texts:
For a certain contract A to execute and transfer specific amounts to other sub-contracts, I need a way to determine all the contributors amounts and addresses and make certain computations before configuring the details and amounts in the sub-contracts. Because of this, off-chain inspection of the blockchain will not suffice

What alternatives are there for designing this?


texts: Is there a way to store data on ethereum blockchain without anybody knowing about it

texts:
Lets say I am building a contract where I want to store some important information on ethereum blockchain. The data should be hidden and people shouldn't have a way to see it.

As per my knowledge, every transaction on ethereum blockchain is open and every one can see the inputs of the transaction. Is this correct?

If I want to make a function payable and want to store a password in this function then would I be able to store the password in raw format? Lets assume I can't encrypt it before sending it to blockchain as my contract needs to do some calculation on top of it.

Given all these conditions, Is there a way I can achieve this on Ethereum blockchain?


texts:
I'm thinking of a service that unconditionally gives out ERC20 based tokens once a user scans a specific QR code that I have created (It may be a random passphrase, address etc...)
Is there a way to make this process automatic on my solidity contract?


texts:
When creating raw transactions, do I have to increase the nonce always in increments of 1 or can I use any nonce as long as it has not been used before?

Are there any specific rules? Could I also go up and down, like transaction #5 gets nonce 17 and transaction #6 gets nonce 13?

Can I use any nonce as long as it is not previously been used?


texts: 2 mapped structs with an address array - push not working

texts:
Can someone help me understand why the function add in the contract one is not working and in the contract two is?

Both are mined and are inserted into the blockchain.

Thanks.

Not working contract

contract one {
    struct A {
        address[] count;
    }
    struct B {
        uint8[] count;
    }

    mapping (address => A) a;
    mapping (address => B) b;

    function add(address c, uint8 g) {
        a[msg.sender].count.push(c);
        b[msg.sender].count.push(g);
    }
}

Working contract

contract two {
    struct A {
        address[] count;
    }

    mapping (address => A) a;

    function add(address c) {
        a[msg.sender].count.push(c);
    }
}


texts: I have an ERC-20 token created. How does it get value now?

texts:
Ok, so a friend of mine helped me create an Ethereum token for me with a 1M supply. I call it the POTTA token. I have also started distributing my token to other friends with a tool that he built so I sent some POTTA tokens to a few friends. As of right now, everything is obviously valued at $0. I just wanted to know how do I add value to my token. So for example if I want each token to be worth say $0.0001 how do I do it?

This is the token contract:

https://etherscan.io/token/0xd521849Fee7901f483Ac06c065225D2497aC0184


texts: I will start with fifteen mining rigs next week (each 6 GPUs). I have two options one is RX470 and other one is RX580 which one should i go with?


texts: I would like to update Mist to the latest version. In the github GitHub page i ve found the latest Windows installer but there is no updater.  How do I go about updating Mist?


texts: Geth stops working after being fully synced

texts:
I have a Geth server in full mode. It was synced fully and I was using it normally for weeks. Today, I wanted to check the synchronization status, so I used geth attach command to enter to the Geth console. I faced to this error:

Fatal: Failed to start the JavaScript console: api modules: Post http://127.0.0.1:2555: dial tcp 127.0.0.1:2555: connect: connection refused

I did not have any change on this server and as I said, it was working well. Now, when I want to run Geth again, it stops working with the below output:

WARN [05-09|16:30:02.576] Sanitizing cache to Go's GC limits       provided=16384 updated=5220
INFO [05-09|16:30:02.579] Maximum peer count                       ETH=50 LES=0 total=50
INFO [05-09|16:30:02.580] Smartcard socket not found, disabling    err="stat /run/pcscd/pcscd.comm: no such file or directory"
INFO [05-09|16:30:02.582] Starting peer-to-peer node               instance=Geth/v1.9.12-stable-b6f1c8dc/linux-amd64/go1.13.8
INFO [05-09|16:30:02.582] Allocated trie memory caches             clean=1.27GiB dirty=1.27GiB
INFO [05-09|16:30:02.582] Allocated cache and file handles         database=/mnt/geth/chaindata cache=2.55GiB handles=524288

What is the problem for? May you help me please?


texts:
Are state changes reversed if the contract "crashes" during execution?

I know that state changes are reversed, if the contract runs out of gas during execution.

However, are state changes also reversed if the contract crashes by execution an invalid instruction?

If the contract chrashes, how much gas is consumed? The gasLimit or gas consumed up until that point?


texts:
I'm trying to call the exchange proxy 2 in truffle console with web3.js and i get a VM Exception while processing transaction: revert. My truffle console is pointing to a ganache-cli mainnet fork based off of infura. The balancer method returns a struct. Could that be the reason it fails? What else could I be doing wrong? Seems like a fairly straight forward thing but I can't for the life of me understand what I'm doing wrong. Passing those exact same arguments to the etherscan read contract page doesnt throw the error...
// abi retrieved from etherscan for this address
contract = new web3.eth.Contract(abi, "0x3e66b66fd1d0b02fda6c811da9e0547970db2f21");
contract.methods.viewSplitExactIn(
    "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
    "0x6B175474E89094C44Da98b954EedeAC495271d0F",
    1000000, 4).call()


texts: List of ALL Ethereum Contract Events, for ex: Transfer, Mint, etc

texts:
A very simple question, yet couldn't find a simple answer.

Where can I find a list of all event types such as Transfer, Mint, etc? Is this stored anywhere, for ex: online database or historically within a Geth or Parity archive node?

Thanks


texts:
On many occasions, I'd like to quickly connect to a local or remote node via web3.js and query for things directly from the console. I imagine something like:

web3-cli set --host http://localhost:8545
web3-cli eth --get-accounts

The first command would switch over to the given host, and when you query for accounts or others things it connects to that HttpProvider in the backend.

Is this possible? I've seen David Knott from OmiseGo created a nice cli for plasma-mvp, so why not upgrade the idea to a general-purpose, handy terminal tool?

Note: I'm already running node in the console, but it's not the same sweet level of flexibility provided by a cli.


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

texts:
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 {
    function mint(address account, uint256 amount) public onlyMinter returns (bool) {
        _mint(account, amount);
        return true;
    }
}

Minter role info is:

truffle(develop)> instance.isMinter(accounts[0])
true
truffle(develop)> instance.isMinter(accounts[1])
false
truffle(develop)> instance.isMinter(accounts[2])
false
truffle(develop)> instance.isMinter(accounts[3])
false

However,when I try to mint token, I found the modifier can not take effect to control the function call right:

For the first account:

truffle(develop)> instance.mint(accounts[0],1000)
{ tx:
   '0x323ff19c7b79cbe545914465c9bda87aa5169cdaa3be6f4ccbebcd7e7eb76617',
  receipt:
   { transactionHash:
    ...
truffle(develop)> instance.totalSupply()
<BN: 3e8>//1000

For the second account:

truffle(develop)> instance.mint(accounts[1],1000)
{ tx:
   '0xc13da9ca6ba8b74e998b4b158eb1be02208e2bc8f08c789f4a6a306bedadc7a1',
  receipt:
   { transactionHash:
truffle(develop)> instance.totalSupply()
<BN: 7d0>//2000
truffle(develop)> instance.balanceOf(accounts[0])
<BN: 3e8>//1000
truffle(develop)> instance.balanceOf(accounts[1])
<BN: 3e8>//1000
truffle(develop)> instance.balanceOf(accounts[2])
<BN: 0>

From the result, every account is able to mint token, onlyMinter has no capability to control function call role.

How can I fix the problem?
Thanks.


texts: Unable to store/retreive the value of an inherited attribute

texts:
Contract code:

pragma solidity ^0.4.11;

contract Base {
    uint stored;
    function set (uint _stored) {
        stored = _stored;
    }
    function get () constant returns (uint) {
        return stored;
    }
}

contract Child {
    Base b;
    function set (uint _stored) {
        b.set(_stored);
    }
    function get () constant returns (uint) {
        return b.get();
    }
}

Deployed as:

var i_sol_baseContract = web3.eth.contract([{"constant":false,"inputs":[{"name":"_stored","type":"uint256"}],"name":"set","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"get","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"}]);
var i_sol_base = i_sol_baseContract.new(
   {
     from: web3.eth.accounts[0],
     data: '0x6060604052341561000c57fe5b5b60c68061001b6000396000f30060606040526000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806360fe47b11460445780636d4ce63c146061575bfe5b3415604b57fe5b605f60048080359060200190919050506084565b005b3415606857fe5b606e608f565b6040518082815260200191505060405180910390f35b806000819055505b50565b600060005490505b905600a165627a7a72305820bcd4b3fa50cc6fc6b02c37155d3b2a414e76e8e152dc32cb9d7b75e06e5dfca60029',
     gas: '4700000'
   }, function (e, contract){
    console.log(e, contract);
    if (typeof contract.address !== 'undefined') {
         console.log('Contract mined! address: ' + contract.address + ' transactionHash: ' + contract.transactionHash);
    }
 })

var i_sol_childContract = web3.eth.contract([{"constant":false,"inputs":[{"name":"_stored","type":"uint256"}],"name":"set","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"get","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"}]);
var i_sol_child = i_sol_childContract.new(
   {
     from: web3.eth.accounts[0],
     data: '0x6060604052341561000c57fe5b5b6102078061001c6000396000f30060606040526000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806360fe47b1146100465780636d4ce63c14610066575bfe5b341561004e57fe5b610064600480803590602001909190505061008c565b005b341561006e57fe5b61007661012e565b6040518082815260200191505060405180910390f35b600060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166360fe47b1826040518263ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180828152602001915050600060405180830381600087803b151561011957fe5b6102c65a03f1151561012757fe5b5050505b50565b6000600060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16636d4ce63c6000604051602001526040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401809050602060405180830381600087803b15156101be57fe5b6102c65a03f115156101cc57fe5b50505060405180519050505b905600a165627a7a72305820a394fde97515faefe918adeb9034603b30ce48d9f132e9ea9b29823befd3d12b0029',
     gas: '4700000'
   }, function (e, contract){
    console.log(e, contract);
    if (typeof contract.address !== 'undefined') {
         console.log('Contract mined! address: ' + contract.address + ' transactionHash: ' + contract.transactionHash);
    }
 })

Setting and getting the value works when I call set and get on the base contract. However, get from the Child always returns 0. What is wrong in this situation?

Output from geth:

> i_sol_base.set(100, {from: eth.coinbase})
"0x4b35370e66082ec3eb88af8aa4c8bce64a9149daa479fdd17256b2208bd9a90a"
> i_sol_base.get()
100
> i_sol_child.set(200, {from: eth.coinbase})
"0xb9e8464468dfed83fd6d3f369bae229cf4e06de892e30f39080340c3247da777"
> i_sol_child.get()
0
> i_sol_child.get({from: eth.coinbase})
0


texts: Designing a smart contract to do trustless transactions of eth/tokens between users (buyer/seller)

texts:
I'm looking for any help og pointers, as to the possibility of creating a contract that would act as a "middleman" in a token/eth transaction between 2 users.

Considering a website, were users can list their assets (tokens) for sale at a given rate, and other can give their bid, and if the parties agrees to complete the deal, a smart contract should handle the transaction, to ensure trust in the deal.

Through the website, both seller and buyer calls a function on the smart contract, and thereby sending tokens / Eth to the contract. When both have done so, the last transfer calls an exchange function which will exchange the assets between the users.

I can't see any other way, than the website needs to control and monitor the transactions, this is in essence my question. What would be the best way to create such a transaction in terms of design?


texts: Restore ETH from the Ethereum Wallet app from 2018

texts:
hope you can help me with this issue.
In 2018, I downloaded the Ethereum Wallet App (https://github.com/ethereum/mist/releases) and transfered my Ethereum from my Kraken account (https://www.kraken.com/) to this wallet, I think it was because a chain split or something has been announced and Kraken did not support this yet. Well, I remember to have my ETH in the wallet back then and didn't touch them anymore.
Now I wanted to get them from my old laptop but somehow this Ethereum Wallet app does not work anymore. I can open it on my old laptop but it does not find any peers and the balance is shown as 0. I installed the same app on my new laptop with the newer version but it just opens the window with a loading screen which never stops loading. Since I stored my keystore file, I read online I can install MyCrypto app and access the account there, but when I open the keystore file from the MyCrypto app, it shows me a balance of 0 ETH as well. Also, wenn i copy my address into etherscan or others, it shows me now transaction history and a balance of 0.
Can anyone help me with this? Is it maybe deprecated and therefore I see a balance of 0 and how can I retrieve my ETH?
thanks in advance!


texts:
I'm running Parity in warp mode on Mac OSX:

  parity --warp --rpcapi "web3,eth,personal"

Then I open a new terminal and run:

  node
  Web3 = require("Web3")
  web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"))

However, I've heard RPC is not as safe as IPC. Is this true? Why? And how do I connect via IPC instead. Some explanation would be helpful as the difference between IPC and RPC is a bit nebulous for me.

Thank you.


texts: Can we use both centralized and decentralized approach for developing DAPP?

texts:
I saw a dapp using Decentralized approach for the buying and selling ERC20 Tokens ..But there's no proof of using the functions defined in smart contract in the web3js library.How is that possible ?..What am I missing here??
I know, Smart contract code is on etherscan..Another scenario is, The Dapp take notes of the users data and authorized them based on their credentials..I don't see any code  related user structure in web3js nor solidity...Instead they use PHP with a form to check if the credentials match..but they do use Metamask or Trust Wallet..So is it centralized or decentralized approach or combination of both.. is it possible to do so??


texts:
Consider the following contract in Solidity:

pragma solidity ^0.4.2;

contract Registry {
    struct Name {
        string first;
        string last;
    }

    mapping(address => Name) reg;

    function newName(string first, string last) {
        address sender = msg.sender;

        if(reg[sender] != 0) {
            throw;
        }

        reg[sender].first = first;
        reg[sender].last = last;
    }
}

In the if statement above, which is incorrect, I would like to check whether the struct Name is defined, or is still in the default value with all fields initialized to zero. Is there a language operator to do it?


texts: Are there any security issues to send token in fallback function?

texts:
I want to have a contract that releases an erc-20 token as soon as someone pays ether to contract. Let's call this contract Bid Contract.
The abstract code goes like:

function askForTokens() public payable returns(bool){
    uint coins = msg.value / rate;
    token.transfer(msg.sender, coins);
    BidSuccessful(msg.sender, rate, msg.value, coins);
    return true;
}

function() payable{
    askForTokens();
}

So, now when someone sends ethers to contract from his wallet, the fallback functions gets executed and which in turn calls the askForToken function that will send corresponding tokens to msg.sender.

I have tested the functionality and this seems to be working fine.

What I am concerned about is is there any security threat in this implementation?

I can find everywhere suggestion of not writing the logic in fallback function, is the only reason is gas or this makes the contract more vulnerable?


texts: how many internal transaction can be processed?

texts:
I want to transfer ETH to all recipients from recipient contract like below.

What is the limit of 'total'? for average.

How much gas for one internal transaction? Is it 500?

If 500 is right, 16,000 internal transactions can be processed?
(gas limit for a block is approx 8,000,000 and I divide it by 500)

function return() public {
    uint256 total = recipient.getTotalNumber();
    for(uint256 i = 0; i < total; i++) {
        recipient.getAddress(i).transfer(recipient.getAmount(i));
    }
}


texts: How could we see the amount of liquidity provider's injection and drains for each pool? Uniswap, pangolin?

texts:
I try to see the amount of liquidity provider's injection and drains for each pool from start day to now.
Is the relationship between "LP's injections/drains" and "pairs price" for each pool?
Is there anybody help me ?


texts: How to sync wallet files with different servers on private blockchain

texts:
We have a private blockchain setup with three instances on ubuntu 16.04. Each instance consists of 3 authorities to achieve availability in case of failure by redirecting to another instance.

Folder structure (instance-1), same on rest of the instances
blockchain
├── genesis.json
├── node1
│   ├── geth
│   ├── keystore
│   ├── password.txt
│   └── static-nodes.json
├── node2
│   ├── geth
│   ├── keystore
│   ├── password.txt
│   └── static-nodes.json
└── node3
    ├── geth
    ├── keystore
    ├── password.txt
    └── static-nodes.json

We have code to create users, so when a new user is registered, the system will create a wallet file in node1 > keystore folder. When a user wants to perform some operation, they will provide a wallet password and the system will unlock the wallet and then perform a transaction.
The same setup exist on another server.
The issue is, assume user-1 is registered, the wallet file will be generated into instance-1. Now, the first instance is down for any reason, so, truffle hd-wallet provider will redirect user-1 to instance-2. The system will check for the wallet file, but the system couldn't find there as the wallet was created on the instance-1.
So, the question is; how to sync wallet files between servers?


texts: Are NFTs (technically, the smart contracts) stateless or stateful?

texts:
Are the smart contracts used to manage NFTs stateless or stateful?
Ethereum as a protocol seems to be stateful, but the smart contracts for NFT marketplaces seem to be stateless.
They don't save any data between executions of the smart contract, which is my current (and possibly mistaken) understanding of what makes a smart contract stateful.


texts: Why other blockchain would be better for monetary purposes than Ethereum?

texts:
I have seen a comment multiple times that other blockchains would be better for storing value in monetary purposes than Ethereum. Why is that said? UTXO? Volatility?

The comment has been brought up related on long term investement and monetary discussions. I haven't found any technical reason for that, only ideological, that it's not the main purpose of Ethereum.


texts: Why does Ethereum have gas?  What other approaches could Ethereum have used to work around the Halting Problem?


texts: How to cancel pending transaction of ethereum from exchange wallet? It is pending for around 36 hours now. There is no available tx hash.


texts: Why I cannot use multiple dynamically-sized variables in Solidity?

texts:
The following code snippet does not work.

pragma solidity ^0.4.11;

contract Test1 {
    uint[] public a;
    uint[] public b;

    function putX(uint x) public {
        a.push(x);
        b.push(block.number);
    }

    function getA() public view returns (uint[]) {
        return a;
    }

    function getB() public view returns (uint[]) {
        return b;
    }
}

Output:

> test1.putX.sendTransaction(11, {from: eth.accounts[0]})
> test1.getA()
[]
> test1.getB()
[]

The following code snippet, in contrast, works.

pragma solidity ^0.4.11;

contract Test2 {
    uint[2][] public a;

    function putX(uint x) public {
        a.push([x, block.number]);
    }

    function getA() public view returns (uint[2][]) {
        return a;
    }
}

Output:

> test2.putX.sendTransaction(12, {from: eth.accounts[0]})
> test2.getA()
[[12, 1151]]

I'm wondering why... I'm using the latest stable geth (1.7)

I also tried to use a dynamically-sized array + a mapping, and it does not work, either.

I even doubt if the code in the official document can work, since it uses multiple dynamically-sized variables:

https://solidity.readthedocs.io/en/develop/solidity-by-example.html

Does anyone know why this happened?


texts: Empty contract.methods Using web3 JS 1.0.0-beta30

texts:
I'm attempting to call a method on a locally deployed contract with the following code using web3 JS 1.0.0-beta30.

const tradingCardABI = JSON.parse(fs.readFileSync('build/contracts/TradingCard.json')).abi;

const ownerAddress = process.env.OWNER_ADDRESS || '0x627306090abaB3A6e1400e9345bC60c78a8BEf57';
const contractAddress = process.env.CONTRACT_ADDRESS || '0xf25186b5081ff5ce73482ad761db0eb0d25abfbf';

const tradingCardContract = new web3.eth.Contract(tradingCardABI, contractAddress);

console.log(`contract json interface=${JSON.stringify(tradingCardContract.options.jsonInterface)}`);
console.log(`contract models=${JSON.stringify(tradingCardContract.methods)}`);

I get contract methods={} in the console. Any thoughts?


texts: How do I remove accounts using the Geth console?

texts:
I have several accounts I've created in the Geth console using:

personal.newAccount()

I no longer use (nor have any intention of using) the first couple of accounts I created, meaning whenever I reference an active account I have to set the account array index to something other than 0.

How do I remove the unused accounts so I can just reference my active account using eth.accounts[0]?


texts: Is there any free-to-use scenario builder?

texts:
The Compound Protocol has a collection of high-level integration tests, dubbed "scenarios":
https://github.com/compound-finance/compound-protocol/tree/v2.8.1/spec
Which look like this:
Test "Mint 1 cZRX"
    NewComptroller
    ListedCToken ZRX cZRX initialExchangeRate:1e9
    Prep Geoff Some ZRX cZRX
    Mint Geoff 50e18 cZRX
    Assert Equal (Erc20 cZRX TokenBalance Geoff) (Exactly 50e9)
    -- Assert Equal (CToken cZRX UnderlyingBalance Geoff) (Exactly 1.0e18)

These are built with Certora, which bears a cost.
Is there any free tool that can do this or something alike?


texts: Is it possible to call another contract and not pay transaction cost(~20k gas)?

texts: The thing is that I need to reach the maximum stack depth. When I try to recursively call myself I run out of gas, because each call requires  at least ~20k gas.


texts: How to create a smart contract which hold different erc20 tokens or ETH?

texts:
I want to make a simple smart contract.
where any user can send ETH (or any ERC20 token) to the smart contract.
but how to keep track of every token, their weight in the smart contract, and the overall valuation/percentage in the smart contract...
any reference will be helpful for the implementation.
Thank you for helping!


texts: Transferring an ERC20 token from one address to another

texts:
I'm using web3 to transfer an ERC20 token (for a contract already deployed on the Ethereum blockchain) from one address to another.

The code I'm using is shared below:

// script.js
Web3 = require('web3')
web3 = new Web3(new Web3.providers.HttpProvider("https://mainnet.infura.io/APIKEY"))

// Contract details
const contractABI = require('human-standard-token-abi')
const contractAddress = "0x039b5649a59967e3e936d7471f9c3700100ee1ab"
const decimals = 6;
const value = 0.01 * 10 ** decimals;

// Destination address
const toAddress = "0x130FCE6849E094b36816975a1632062BF65642D8";
web3.eth.accounts.wallet.add("PRIVATEKEY")

// Transfer
contract = new web3.eth.Contract(contractABI, contractAddress, {
             from: web3.eth.accounts.wallet[0].address,
             gas: '100000'})
contract.methods.transfer(toAddress, value).send({}, function(err, txHash) {
  console.log(err, txHash);
});

When I run this script node script.js, I get the below error:

Error: Invalid JSON RPC response: ""
    at Object.InvalidResponse (/Users/rock/Desktop/vote/node_modules/web3-core-helpers/src/errors.js:42:16)
    at XMLHttpRequest.request.onreadystatechange (/Users/rock/Desktop/vote/node_modules/web3-providers-http/src/index.js:60:32)
    at XMLHttpRequestEventTarget.dispatchEvent (/Users/rock/Desktop/vote/node_modules/xhr2/lib/xhr2.js:64:18)
    at XMLHttpRequest._setReadyState (/Users/rock/Desktop/vote/node_modules/xhr2/lib/xhr2.js:354:12)
    at XMLHttpRequest._onHttpResponseEnd (/Users/rock/Desktop/vote/node_modules/xhr2/lib/xhr2.js:509:12)
    at IncomingMessage.<anonymous> (/Users/rock/Desktop/vote/node_modules/xhr2/lib/xhr2.js:469:24)
    at emitNone (events.js:111:20)
    at IncomingMessage.emit (events.js:208:7)
    at endReadableNT (_stream_readable.js:1056:12)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickDomainCallback (internal/process/next_tick.js:218:9) undefined

This error is from the last line, where I make the transfer() call. I've tried calling a method that doesn't change state (e.g. contract.methods.balanceOf(toAddress).call() and that works fine.

Please help.


texts:
This is my code, a simple lottery contract, saves the address participants in the mapping, it is not finished but i want to test if i can receive the payment

pragma solidity ^0.4.23;

contract Lottery {

  uint lotteryFee = 0.1 ether;
  uint8 counter = 0;
  mapping (uint8 => address) participants;

  function participate() external payable returns(address) {
    require(msg.value == lotteryFee);
    counter = counter + 1;
    participants[counter] = msg.sender;
    return(participants[counter]);
  }

  function getBalance() public returns (uint) {
    uint contractBalance = address(this).balance;
    return(contractBalance);
  }
}

and my test is this:

pragma solidity ^0.4.23;

import "truffle/Assert.sol";
import "truffle/DeployedAddresses.sol";
import "../contracts/Lottery.sol";

contract TestLottery1 {
  Lottery lottery = Lottery(DeployedAddresses.Lottery());
  //Testing the participate() function
  function testUserCanParticipate() public {
    address returnedId = lottery.participate();
    address expected = msg.sender;
    Assert.equal(returnedId, expected, "You are participating");
  }
}

how or where i put the value i want to send to the contract?


texts: How do we add values into the below struct ? Am a newbie here! Thanks in advance!

texts:
pragma solidity ^0.5.8;

contract DriverRegister {

    enum CarType {mini, micro, prime}

    struct Driver {
        string name;
        uint phno;
        uint licenceno;
        bool isDriverRegistered;
        CarType cartypes;
        uint index;
    }

    mapping(address => Driver) public driverStructs;
    address[] public drivers;

    function registerDriver(string memory _name, uint _phno, uint _licenceno) public {

    }
}

In such a way, that it can be retrieved using a unique id? Is that even possible?


texts: Solidity opcode error when sending coin to an address

texts:
So I get the error below when attempting to send the coins to another address, and with the debugger, I can't figure out where's the problem. What am I doing wrong? (I just started learning solidity a few days ago).

pragma solidity ^0.4.0;

contract HelloWorld {

    mapping (address => uint) balances;
    address owner;

    event Transfer(address indexed _from, address indexed _to, uint256 _value);

    function HelloWorld() {
        balances[msg.sender] = 1500;
        owner = msg.sender;
    }

    function getBalances(address addr) returns(uint) {
        return balances[addr];
    }

    function getOwner() returns(address) {
        return owner;
    }

    function sendCoin(address receiver, uint amount) returns(bool success) {

        if(balances[msg.sender] < amount) return false; // Check amount of coins

        balances[msg.sender] -= amount;
        balances[receiver] += amount;

        Transfer(msg.sender, receiver, amount);
        return true;
    }
}

Error:


texts: not able to locate the block various declaration

texts:
I am not able to locate, the declaration of the following variables (Time, ParentHash, Extra, etc.) in go-ethereum. It is the part of the core/genesis.go program

  Variable:

            Time:       common.String2Big(genesis.Timestamp),
            ParentHash: common.HexToHash(genesis.ParentHash),
            Extra:      common.FromHex(genesis.ExtraData),
            GasLimit:   common.String2Big(genesis.GasLimit),
            Difficulty: difficulty,
            MixDigest:  common.HexToHash(genesis.Mixhash),
            Coinbase:   common.HexToAddress(genesis.Coinbase),
            Root:       root,

I found the declarations in core/types/block.go, but those declarations are not mapping with this. I wish to add additional parameter in the block. I would like to do it in private network.


texts:
What happens if you transfer real tokens to a test account?
The Ethereum wallet says that you shouldn't do it, but it doesn't say why.


texts: How to get rid of large amounts of my own custom tokens?

texts:
Consider this hypothetical scenario:

Let’s say I created an ERC20 token just for fun. I keep 1 billion of these tokens for myself.

I list this token on a small exchange. And then by some miracle the price of this token rises to $1. Is there any way I can get rid of all my tokens at this very moment and make a $1 billion profit - despite the obvious low liquidity of my custom token?

I’m asking this because I’m wondering how scammers can create large amounts of new coins/tokens and then dump them en masse despite low liquidity?


texts: how generate this address and how i can change this address

texts:
this address how generate and how i can specify this address

im new in blockchain please explain for me. what is this


texts:
Currently, the gas limit imposes an upper bound on the amount of computation that can be done in an Ethereum smart contract.  Part of the purpose of this limit is to upper-bound the burden on miners and verifiers.

There are various proposals for sharding, which would allow the Ethereum blockchain to scale to a larger number of transactions.  Would sharding allow increasing the gas limit?  Do any of the existing sharding proposals propose to increase the gas limit, and by how much?


texts: Tokens are not being transferred with web3js

texts:
i have been using following code for transferring tokens from wallet to another with the use of web3js.

async Transfer(eth_address, amount){
  let tokenAddress = "0x6CbEDEc4F1ac9D874987D2769596544E0d9161ab";
  let sendAmount  = web3.utils.toWei(amount.toString(), 'ether')
  const consumerContract = new web3.eth.Contract(config.ERC20contractAbi, tokenAddress);
  const myData = consumerContract.methods.transfer(eth_address, sendAmount).encodeABI();
  const tx = {
    from,
    to:eth_address,
    value: '0',
    gasPrice: web3.utils.toWei('25', 'gwei'),
    gas: 60000,
    chainId: 1,
    nonce: await web3.eth.getTransactionCount(from,'pending'),
    data: myData
  }
  const signed = await web3.eth.accounts.signTransaction(tx, privateKey)
  const rawTx = signed.rawTransaction
  const sendRawTx = rawTx =>
  new Promise((resolve, reject) =>
    web3.eth
      .sendSignedTransaction(rawTx)
      .on('transactionHash', resolve)
      .on('error', reject)
  )

  const result = await sendRawTx(rawTx).catch((err) => {
      return err
  })

  if(result.toString().includes('error')){
    return result
  }
  else{
    return result
  }

},

But now it is suddenly not working for me. I do receive transaction hash and it is also marked as success on etherscan.io. Here is the link
https://etherscan.io/tx/0xa92a7181275474cd6bd00e6e220385230c0c275e98d63bc35570ba6c0f9c4ab9

As it can be observed that there is no information about token being transferred or not. I have been using same method for a while, i don't understand what i am doing wrong now. kindly Guide regarding this. Thanks


texts: How KYC ICO check addresses during crowdsale?

texts:
I see more ICO are complying with KYC. I wonder what exactly means for the crowdsale smart contract. Is the latter rejecting eth coming from unregistered addresses? Then, how is this managed? With a huge table inside the crowdsale?

Thx for any clue.


texts: How to fund account for parity private chain?


texts: What happens when run in command line: geth?

texts: I set up geth and then I run: geth. It seems to be downloading something ? So what the heck is it doing ?


texts: DeclarationError: Identifier not found or not unique when deploying a facotry contract

texts:
I am using truffle with angular to write DAPP. I have a factory contract which will deploy an other contract named rental through a function called newContract. here is my factory contract

pragma solidity ^0.4.8;
import './RentalContract.sol';

contract ContractFactory {
  address[] public contracts;

  function ContractFactory() {
  }
  function getContractCount() public constant returns(unit contractCount) {
    return contracts.length;
  }

  function newContract(unit _rent, unit _security_deposit, string _house, address _owner, address _tenant)
  public returns(address newContract) {
    Rental c = new Rental(_rent, _security_deposit, _house, _owner, _tenant);
    contracts.push(c);
    return c;
  }
}

and my Rental contract looks like following.

pragma solidity ^0.4.8;

contract Rental {
    struct PaidRent {
        unit id;
        unit value;
    }
    PaidRent[] public paidrents;

    unit public createdTimestamp;
    unit public rent;
    unit public security_deposit;
    string public house;
    address public owner;
    address public tenant;

    enum state {Created, Started, Terminated}
    State public state;
    function Rental(unit _rent, unit _security_deposit, string _house, address _owner, address _tenant) {
        createdTimestamp = block.timestamp;
        rent = _rent;
        security_deposit = _security_deposit;
        house = _house;
        owner = _owner;
        tenant = _tenant;
    }
    modifier require(bool _condition) {
        if(!_condition) throw;
        _;
    }
    modifier LandlordOnly() {
        if(msg.sender != landlord) throw;
        _;
    }
    modifier TenantOnly() {
        if(msg.sender != tenant) throw;
        _;
    }
    modifier inState(State _state){
        if(_state != state) throw;
        _;
    }

    function getPaidRents() internal returns (PaidRent[]) {
        return paidrents;
    }

    function getHouse() constant returns (String) {
        return house;
    }
    function getLandlord() constant returns (address) {
        return landlord;
    }
    function getTenant() constant returns (address) {
        return tenant;
    }
    function getRent() constant returns (unit) {
        return rent;
    }
    function getDeposit() constant returns (unit) {
        return security_deposit;
    }
    function getContractCreated() constant returns (unit) {
        return createdTimestamp;
    }
    function getContractAddress() constant returns (address) {
        return this;
    }
    function getState() returns (State) {
        return state;
    }
    function CollectEth() payable  {}

    function payRent() TenantOnly inState(State.started) require(msg.value == rent) {
        landlord.transfer(msg.value);
        paidrents.push(PaidRent({
            id : paidrents.length + 1,
            value : msg.value
        }));
    }

    function terminateContract(address deposit_to) inState(State.started) require(this.balance == security_deposit) {
        deposit_to.transfer(security_deposit);
        state = State.Terminated;
    }

}

but when i run truffle compile i am having following error.

any idea what is wrong here?


texts:
I have a question related to ERC1820 : Pseudo-introspection Registry Contract

in the offical link (http://eips.ethereum.org/EIPS/eip-1820)

in ERC1820Registry implementation contract what is the reason for defining
mapping(address => mapping(bytes32 => address)) internal interfaces;

Why can't it defined as mapping(bytes32 => address) which provides the address of contract which implements the given _intefaceHash argument.

I m missing anything imp here?

Regards


texts: Can I get the ABI and contract code from the deployed address?

texts:
If I have the address of the solidity contract, can I from that address determine the source code and the ABI?

I mean by this, is there a function to call in etherscan or something like that?


texts: How to store and access large amount of data in block chain?

texts:
I am trying to implement Role based access control mechanism using block chain.
My model consists of two tables(user assignment and role assignment) which contains 500 entries each.So, I can't enter the entries in table manually.
After storing these tables, my smart contract would be able to allow or deny the access of user request.
So, how could I store and read these tables?
I hope someone helps! Thank you in advance.


texts: I see many ICOs state that they will burn unsold tokens, is this just to increase price and/or crowdsale participants expect them to?


texts: Truffle console no compile or init options

texts:
While using truffle.cmd console I tried to use the compile option, or even init.
These options are not available, so I cannot compile using console.

truffle(development)> .help

.break    Sometimes you get stuck, this gets you out

.clear    Break, and also clear the local context

.editor   Enter editor mode

.exit     Exit the repl

.help     Print this help message

.load     Load JS from a file into the REPL session

.save     Save all evaluated commands in this REPL session to a file

truffle(development)>

I tried using truffle in PowerShell but still no resolution: could not see compile, or init options, when using .help


texts: Transaction taking too long on Ropsten testnet

texts:
I checked the syncing status, it returns false. I submitted transaction with a very high gas value but it takes long time to get completed. This is my local ropsten node:

INFO [08-06|13:16:45.473] Imported new chain segment               blocks=20 txs=485 mgas=36.216 elapsed=8.801s    mgasps=4.115  number=3781888 hash=c6044b…699f1f cache=14.53mB
INFO [08-06|13:16:54.141] Imported new chain segment               blocks=33 txs=513 mgas=48.793 elapsed=8.668s    mgasps=5.629  number=3781921 hash=eedfea…5493ef cache=14.97mB
INFO [08-06|13:16:55.307] Imported new chain segment               blocks=5  txs=85  mgas=11.554 elapsed=1.166s    mgasps=9.905  number=3781926 hash=90df4a…40f450 cache=15.09mB
INFO [08-06|13:18:17.611] Submitted transaction                    fullhash=0x84053eabcb71a8081832d17b10b5145fd292fcce9fb1fa9d5b3694812c9ade1f recipient=0x830954070CA0051Eb6941314158c0A65CF756296
INFO [08-06|13:19:52.805] Submitted transaction                    fullhash=0xfdccd022ef614bd73318272212fd765428882c6d988177a611286247edae9b2b recipient=0x830954070CA0051Eb6941314158c0A65CF756296
INFO [08-06|13:20:09.826] Submitted transaction                    fullhash=0x6011cdf5281e82e8a1143e32248061f364290cb7005d033c663cabc2dc2c962d recipient=0x830954070CA0051Eb6941314158c0A65CF756296

INFO [08-06|13:21:01.424] Submitted transaction                    fullhash=0xe7ce20f1d5e6668826aad9bcdf4b96290ac9058ec2f02161621da97101c65242 recipient=0x830954070CA0051Eb6941314158c0A65CF756296
INFO [08-06|13:21:18.071] Imported new chain segment               blocks=2  txs=32  mgas=1.270  elapsed=212.207ms mgasps=5.983  number=3781928 hash=27dcc9…fb721f cache=15.05mB
INFO [08-06|13:21:19.054] Imported new chain segment               blocks=3  txs=17  mgas=0.506  elapsed=125.386ms mgasps=4.032  number=3781931 hash=09bf3f…df3b02 cache=14.91mB
INFO [08-06|13:21:28.149] Imported new chain segment               blocks=8  txs=278 mgas=27.496 elapsed=8.187s    mgasps=3.358  number=3781939 hash=7879aa…e0f9c0 cache=15.22mB
INFO [08-06|13:21:31.078] Imported new chain segment               blocks=11 txs=267 mgas=20.008 elapsed=2.925s    mgasps=6.839  number=3781950 hash=abcd65…d2113f cache=15.36mB

I called contract method through web3.js to add struct(containing 2 string) to a list.


texts: How to customise Ethereum Network Status for a Private Network?

texts:
I am using this - https://github.com/cubedro/eth-netstats

I get this error -

  2018-05-29 04:30:25.958 [API] WS_SECRET NOT SET!!!

I want to show the stats on a private parity PoA network.

Has anyone any suggestions about to configure Eth Netstats for this task? Also is this the main repo? I saw only only 484 stars.


texts:
I'm new into this world.

I (think to) know that usually blocks are mined from most rewarded to less rewarded. So if I offer very low gas price for a transaction, it can be take a long time to be mined, if it will be. Right?

I am thinking if I could setup a miner client to mine ONLY very low-valued blocks, because, I hope, there is less people trying to solve them.

My end goal is to be able to make transactions at a lower cost and be 'sure' that someone will try to mine it anyway

Is it possibile to configure a client to mine only low-valued blocks?

Is it possibile to lower transaction costs creating a pool of low-cost only miners?


texts:
I want to restreint access to my ethereum node (geth) via rpc interface for some machines,
for example : localhost and 10.x.x.x

how to deal with that?


texts: Always Getting "Input" "0x0" from web3.eth.getTransaction(txHash)

texts:
I send a transaction i.e

web3.eth.sendTransaction({
            to: toAddress,
            from: fromAddress,
            value: web3.toWei(amount, 'ether'),
            data : inputData,
        });

But when I am trying to get transaction data from local RPC(Ganache) i.e

web3.eth.getTransaction(tsHash,function(error,data){
            if (error) {

            }else {
               console.log(data);
            }
        });

Return all fields perfectly except "input".i.e

{"hash":"0x6xxxxxcb877","nonce":3,"blockHash":"0x0bxxxxxxx5798","blockNumber":4,"transactionIndex":0,"from":"0x4xxxxxxxx0abb","to":"0x5xxxxxxxxe649","value":"20000000000000000","gas":2000002,"gasPrice":"1000000000","input":"0x0"}


texts: How can Ether be withdrawn from a contract successfully using transfer?

texts:
New to Solidity...

I am studying how to withdraw Ether from a smart contract by setting a parameter in a function. Based on the value the function receives, an amount of Ether is sent to a contract wallet address. My goal is to use address.transfer(amount in wei) as discussed here...

http://solidity.readthedocs.io/en/v0.4.21/units-and-global-variables.html?highlight=.transfer

The issue is I am not able to execute the transfer of Ether from the contract address. I am using Remix in conjunction with a local blockchain, and I have confirmed that all my accounts are unlocked, so I should be able to send ether from this contract.

Below is the source that I am studying with...

The idea is that if a value of 1 - 3 is provided, then 24, 12, or 6 Ether is sent to the address held in variable remMem. I set x = y to verify that the value was received by the function.

pragma solidity ^0.4.18;

contract ETHTEST {

    uint256 public y;
    address public remMem = 0x4152B21f407Ba23c6118c1641821EC4250DBf3B1;

    function transferETH(uint256 x) public payable returns(uint256){
    // y = x;
    // return;

        if (x == 1){

            y = x;
            remMem.transfer(24000000000000000000);
            return;
        }

        if (x == 2){

            y = x;
            remMem.transfer(12000000000000000000);
            return;
        }

        if (x == 3){

            y = x;
            remMem.transfer(6000000000000000000);
            return;
        }

        if (x >=4 || x < 0){  //works
            revert();
            return;
        }

    }

}

How would I code the transfer of Ether successfully? Useful guidance would be most appreciated.


texts: How to add a field to a struct dynamically?

texts:
Suppose we have a proxy contract that separates Data layer from Logic layer.
We have a struct in Data contract, like this:
struct person {
    uint id;
    string name;
}
mapping(address => person) persons;

We have deployed this contract and the Dapp users have entered data in it.
Now suppose we want to change the logic contract and add a birth_year field to the struct. how can we make this change to the struct dynamically? Its final form would be as follows:
struct person {
    uint id;
    string name;
    uint birth_year;
}
mapping(address => person) persons;

Even assembly language is acceptable, but sure Solidity is better.


texts: I lost 2 ETH! I successfully cancelled my transaction, but the 2 ETH was never returned

texts:
public address: 0x6ac5EF890224e2699a89810F0bd2DED90d74Ab37
first Hash tx: 0xfeb6c486a8f17a8b4216bbd2069429a285a1c5da8d15e98d3d66e6bf5488a866
I tried to swap for a coin on uniswap, but it took 7 hours so i tried to increase gas fees.  but after another hour nothing happed.  So i decided to cancel it.  I was able to successfully cancel the transaction but the 2 ETH never returned.
can someone please help!


texts: Store date in base64 string inside contract

texts: I started creating a solidity smart contract to serve almost as both BD and Backend service. Everything was ok until I got a warning saying my contract had too many bytes.. was too big (refering to this EIP). I didn't even had half of my contract done. So I started thinking of a way I could avoid this.. and had the idea to store all my requirements data structure in one single variable (string I suppose) in the form of base64. Meaning that on my contract, there would always just be store the full object in a base64 string form. On a front end I would have to guarantee that my variable gets decoded to read, and coded again to write/update. My question is... is this a bad idea? Is this a thing people often do?


texts: Contract function not sending ethereum as expected

texts:
I'm using MetaMask and making some changes to the Ethereum Pet Shop tutorial. I'm working with two different MetaMask accounts using the Ganache CLI, and when adopt() is called, I'm expecting some eth to be sent back to the previous "owner", or my other account, however, it seems like no eth is being sent from the contract at all.

Here's the code:

pragma solidity ^0.4.19;
contract Adoption {
  struct Pet {
    address owner;
    uint256 price;

  }

  Pet[16] data;

  function Adoption() public {
    for (uint i = 0; i < 16; i++) {

      data[i].price = 500;
      data[i].owner = msg.sender;
    }
  }

  // Adopting a pet
  function adopt(uint petId) public payable returns (uint, uint) {
    require(petId >= 0 && petId <= 15);
    if ( data[petId].price == 0 ) {
      data[petId].price = 100;
    } else {
      data[petId].price = data[petId].price * 2;
    }

    require(msg.value >= data[petId].price * uint256(1));
    returnEth(data[petId].owner,  (data[petId].price / 2));
    data[petId].owner = msg.sender;
    return (petId, data[petId].price);
    //return value;
  }

  function getAdopters() external view returns (address[], uint256[]) {
    address[] memory owners = new address[](16);
    uint256[] memory prices =  new uint256[](16);
    for (uint i=0; i<16; i++) {
      owners[i] = (data[i].owner);
      prices[i] = (data[i].price);
    }
    return (owners,prices);
  }

}

Can anyone point me in the right direction? Thanks.

To clarify, I want to send ethereum from the contract to the previous "owner" of a pet.


texts: Can ERC-20 based stablecoins be confiscated or be subject to legal process?

texts: Can ERC-20 based stablecoins be confiscated or blacklisted? Can I lose my stablecoins? What are differences between stablecoins out there?


texts: Can a smart contract record IP address of a sender?

texts: Can a smart contract record IP address of the one's using it? I mean, is it possible to implement on Solidity?


texts: Could not able to pipe with background geth process

texts:
I am working on a bash script, where it will send my commands to geth through a simple piping. The problem is for each piping I have to create geth process again, which preload my_script.js into geth all over again and this process actually consumes time since my_script.js is large.

echo "net" | sudo geth --datadir --preload "my_script.js" \
      "/home/MyEthereumEbloc" attach ipc:/home/MyEthereumEbloc/geth.ipc

Output (I can obtain the output correctly):

>
{
  listening: true,
  peerCount: 2,
  version: "23422",
  getListening: function(callback),
  getPeerCount: function(callback),
  getVersion: function(callback)
}

I want to pass information as input and get its output result from geth process that works at the background and required to load my_script.js only one time. In order to accomplish this, I have tried piping but I wasn't able to make it work. I am sorry if this question might be related to unix but any additional approach to solve this problem would be appreciated.

mkfifo program.pipe;
cat > program.pipe &
sudo geth --datadir "/home/MyEthereumEbloc" attach \
      ipc:/home/MyEthereumEbloc/geth.ipc console >> output.txt < sudo program.pipe

#On another terminal.
printf "%s\n" "net" >> sudo program.pipe

Thank you for your valuable time and help.


texts: Ethereum extract transactions based on timestamp

texts: I am trying to extract all transactions of Ethereum using the eth scan API. But I need transactions for specific time periods only. I tried running the API for all the blocks to try and extract all transactions from the beginning. But, it gave me a 403 error. Can someone please help?


texts: Why do I pay fee for reading transaction on Ropsten?

texts:
I have a doubt.
I am using truffle with meta mask to deploy Smart Contract, write transaction and read transaction on Blockchain.
Why do I pay fee for reading data on BlockChain? Should it be free?
I have thought it is because I using emit event (so the method is'n view methos).
I am testing on Ropsten Blockchain.
  function getVincitore ()  public returns (string memory, string memory,string memory,string memory )
  {
    require(userCountVincitore>0, "non e` stato sorteggiato nessun vincitore");
    emit Winner ("Il Vincitore", vincitore.username, vincitore.nome, vincitore.cognome,vincitore.email );
    return (vincitore.username, vincitore.nome, vincitore.cognome, vincitore.email);

}

Which are the cases where the transaction are free?
Thanks a lot.


texts: Can solidity bytecode has unreachable code

texts:
I've compiled contract from https://theethereum.wiki/w/index.php/ERC20_Token_Standard (Sample Fixed Supply Token Contract: contract FixedSupplyToken version:0.5.1+commit.c8a2cb62)
I try to make abstract execution of that. But when I've done it, I've discovered that some blocks of code unreachable.
For example:

label_0281:
0281    JUMPDEST
0282    PUSH1 0x40
0284    MLOAD
0285    DUP1
0286    DUP3
0287    ISZERO
0288    ISZERO
0289    ISZERO
028A    ISZERO
028B    DUP2
028C    MSTORE
028D    PUSH1 0x20
028F    ADD
0290    SWAP2
0291    POP
0292    POP
0293    PUSH1 0x40
0295    MLOAD
0296    DUP1
0297    SWAP2
0298    SUB
0299    SWAP1
029A    *RETURN

I can't find from which part of the code, that could have been called.
Where did I make mistake?

When I've decompiled that contract I've found the following:

        var1 = 0x0281;
        var2 = 0x04;
        var3 = msg.data.length - var2;

        if(var3 < 0x60) { revert(memory[0x00:0x00]); }

        var1 = func_022B(var2, var3);

Here label_0281 just ignored


texts:
Anyone can guide me on how to schedule a transaction to be sent once a specific block number is mined?

Thanks


texts: The project is working on a Mac. Cloned from git on an Ubuntu machine while running truffle migrate it fails with: Error: Could not find artifacts for ./mycontract from any sources. Contract file of course exists, and code is working on the other box. What am I missing?


texts:
Many token contracts have unrestricted getter functions for state variables, which seems redundant (eg, see OpenZepplin's ERC20 contract). For example, a contract could have it this way:
uint private _totalSupply;

function totalSupply() view public returns (uint) {
return _totalSupply
}

or this way:
uint public totalSupply;

Web3.js and solidity would use the exact same syntax--totalSupply--to retrieve the variable "totalSupply."  As the former is more common, but also more verbose, I presume I am missing some way in which a getter function dominates querying a contract directly. Can someone enlighten me?


texts: Transaction receipt is 0x1 but the execution failed. How is it possible


texts:
From the Ethereum official documentation:

  The DAG is totally different every 30000 blocks (a 100 hour window, called an epoch) and takes a while to generate. Since the DAG only depends on block height, it can be pregenerated but if its not, the client need to wait the end of this process to produce a block. Until clients actually precache dags ahead of time the network may experience a massive block delay on each epoch transition.

It's mentioned that DAG takes a while to generate. What are the factors effecting this generation time? Is there any faster way to generate DAG? Also, what kind of discrepancies will be observed during this epoch transition in case if the DAGs are not pre-cached.

P.S: In my case (private blockchain), the ethereum node crashed while generating DAG for epoch 1 due to:

panic: ethash_full_new IO or memory error

I'm running geth on an Ubuntu (16.04) Virtual Machine with 3GB RAM.


texts: How to check nonce include pending transactions?

texts:
I want to count nonce include pending transactions as following.

Tx1 nonce=0 succeed
Tx2 nonce=1 pending
Tx3 nonce=2 pending
Tx3 nonce=3 pending

I am using api provided by etherscan, but it just returns nonce for only confirmed transactions. How can I get nonce include pending transactions?


texts:
i have been asking by my client to save ETH when transfer out his USDT, he hope there is no or very little ETH left in his new USDT address. Please assume that USDT address has no initial ETH and next i got to transfer some ETH into it.
after long refer from other old transactions. i decided to use 26500 as gas limit (i assure that the recipient address has USDT) and not long needed ETH come after this and now i have enough gas to transfer USDT.
After broadcast the new tx to network, a moment later i encounter out-of-gas error. I tried with higher gas limit until i give up and set it to 60000. then guess now what, the tx is success! and actual consume gas is even lesser than 26500.
Anybody explain me why this happen? why i cant set exact gas limit to solve my problem? is transfer() in usdt contract has special condition? Thanks in advanced.


texts: solc-js error: "before each" hook for "deploys a contract": SyntaxError: Unexpected token u in JSON at position 0

texts:
The issue is probably here: const { interface, bytecode } = require('../compile');.
interface in the test file is undefined.
inbox/contracts/Inbox.sol:
pragma solidity ^0.7.0;

contract Inbox {
    string public message;

    constructor(string memory initialMessage) {
        message = initialMessage;
    }

    function setMessage(string memory newMessage) public {
        message = newMessage;
    }
}

inbox/compile.js:
const path = require('path');
const fs = require('fs');
const solc = require('solc');

const inboxPath = path.resolve(__dirname, 'contracts', 'Inbox.sol');
const source = fs.readFileSync(inboxPath, 'utf8');

var input = {
    language: 'Solidity',
    sources: {
        'Inbox.sol' : {
            content: source
        }
    },
    settings: {
        outputSelection: {
            '*': {
                '*': [ "abi", "evm.bytecode" ]
            }
        }
    }
};

module.exports = solc.compile(JSON.stringify(input));

inbox/test/Inbox.test.js:
const assert = require('assert');
const ganache = require('ganache-cli');
const Web3 = require('web3');
const web3 = new Web3(ganache.provider());
const { interface, bytecode } = require('../compile');

let accounts;
let inbox;
beforeEach(async () => {
    //get a list of all accounts

    accounts = await web3.eth.getAccounts();

    //use one of those accounts to deploy the contract
    inbox = await new web3.eth.Contract(JSON.parse(interface))
        .deploy({ data: bytecode, arguments: ['Hi there!'] })
        .send({from: accounts[0], gas: '1000000'});
});

describe('Inbox', () => {
    it('deploys a contract', () => {
        console.log(inbox);
    })
})

when running npm run test it throws:
  Inbox
    1) "before each" hook for "deploys a contract"

  0 passing (366ms)
  1 failing

  1) "before each" hook for "deploys a contract":
     SyntaxError: Unexpected token u in JSON at position 0
      at JSON.parse (<anonymous>)
      at Context.<anonymous> (test\Inbox.test.js:15:46)
      at processTicksAndRejections (internal/process/task_queues.js:97:5)


texts: Whats going on with these mysterious ethereum addresses?

texts:
A while ago I found website ethersecret.com which turned out to be very interesting; it provides a search engine for ethereum private keys and their corresponding addresses and whether they hold any ether on them. The downside is that the odds of finding an address with transactions, let alone some eth in it are almost impossible because of statistics.

However, digging a bit I found that most of the the addresses within the first pages had transactions. So I decided to write a simple script to do some tests. The script transferred any incoming eth into these addresses, which some of them received almost daily.

Whenever a transaction came in it would be sent out to another address by a third party pretty much immediately, just 2 blocks after the eth arrived. And then I noticed:

Some of the accounts held some tokens, and a decent amount of them, but etherscan didn't show that these tokens held any actual value. I modified the script to see if I could use whatever eth that came into the account as gas to get the tokens out, but whoever was and is on the other side is faster and always takes the eth before any other transaction can take place and always outbids other transactions. So I eventually stopped trying to figure out what was going on.

But today, I opened for some reason ethersecret.com and it shows the following:

Which is the weirdest thing, because the script that whoever was running always left the accounts in 0 balance, but now for whatever reason a tiny amount of eth is left in them.

My theory is that whoever was on the other side tricked people into sending eth to get these fake tokens out and their script was really good so they would extract all incoming eth at any cost. They used these private keys because they are actually "obvious", and now they are trying to bait even further.

I wonder if it could be the same people who wrote the ethersecret.com website.

Does anyone has any idea of what's actually going on with these "obvious" private keys?


texts: ERC20 Contract transfer call failed multiple times, no idea why

texts:
I found this token that got airdropped on me a while ago, and I don't want it. It was valued at $18 or so.
I decided to sell it, but the exchange had a minimum amount, so I simply bought more so I could get sell the larger sum of the token.
When I tried to send trade back for ETH, the transaction failed. According to etherscan.io, it was a SafeMath: subtraction overflow
I did some digging, and tried to use the approve method to allow myself to spend more. No good, the same thing happened.
Then, somewhere I found that it might be the contract calling the method, not me. So I gave the contract an allowance.
No good.
This is quite frustrating, and I'm already down $40 in transaction fees. I just want this pain to end. How can I get this transfer method to just work?
Relevant txids (in chronological order):
First failure 0x6bd9dfaee6932d0cc145ba1c8ace1fa5c61fa1c15d7a0233a2242336d723f9ad
Trying to give myself an allowance 0x392fc312e517f2eca885a9c70fbb96b6934ac7932326ddb61aeed1bf437393b3
Second failure 0x2bbe31a3d6f383503e70c40b4ff2f851ca7d0d578e483d566f1a6c9ac1201510
Trying to give the contract an allowance 0xf8d5201c46dcc553bf671d71638a4b3ffaac53457afb093d29cb7ca4a5a54eb0
Third failure (hopefully the final one) 0x4f5d7111df2983970fffb915ca85a06667a0b245f85e7112c3117726841a6e7b


texts: Truffle migrate: unknown network "development"

texts:
I'm using macOS High Sierra. I installed truffle and ganache-cli as below

npm install -g truffle
npm install -g ganache-cli

Then I created a directory and cd to it to run the test

mkdir ethereumTest
cd ethereumTest

I initiate the truffle and compile it

truffle init
truffle compile

Since I'm on Mac, I changed the truffle.js file as below

module.exports = {
   network: {
     development: {
        host: "127.0.0.1",
        port: 8545,
        network_id: "*"
    }
  }
};

I opened another terminal and ran ganache-cli
    ganache-cli

But when I tried to migrate to the network in the previous terminal, it gives error

truffle migrate

It gives

Unknown network "[object Object]". See your Truffle configuration file for available networks.

truffle network --network development

It gives

Unknown network "development". See your Truffle configuration file for available networks.

I also tried the following

remove truffle-config.js
change truffle-config.js as the same as truffle.js
In the truffle.js file, change host to localhost

But none of them works, any other suggestion?


texts: Can transfer data through Raiden network?

texts: Is there a way to transfer data through Raiden Network. As i checked their Docs and whitepaper all its mentioned about ERC token transfer. i need to transfer a hash to Etherum rough Raiden network. Is it possible?


texts:
I have the following code

var transactionMessage = new TransferFunction
        {
            FromAddress = accountFrom,
            To = accountTo,
            AmountToSend = tokens,
            Gas = new HexBigInteger(gasPrice)
        };

        var tokenService = new Nethereum.StandardTokenEIP20.StandardTokenService(web, accountTo);
        var transferReceipt = await tokenService.TransferAndWaitForReceiptAsync(transactionMessage);

        return transferReceipt.TransactionHash;

It works great for sending ETH. However I need to modify it to send custom ERC20 tokens. Any ideas how to do it?


texts: Accept ERC20 token payment using web3.js

texts:
I'm accepting Ethereum and Bitcoin payments in an trading site and I persist user balances in a database. I'd like to be able to receive ERC20 tokens too (like Bancor) if possible. I am not creating new token contract, just want to accept them as payment.

As the %90 of the answers on the web, they suggest polling filter event of Transfer(address,address,uint256) using web3.js. Please correct me if I'm wrong, but how will I get corresponding TX of that payment from that event?

I don't have deep knowledge about Ethereum and smart contracts.

Mirror: https://github.com/ethereum/web3.js/issues/1109


texts: How to transfer eth to a solidity function from a Dapp

texts:
I am trying to build a Dapp which includes functionality to deposit funds to a contract and withdraw them.
The functions look like this

function fundContract() public payable {
        require (msg.sender == users[msg.sender].addr);
        users[msg.sender].balance += msg.value;
        contractBalance+=msg.value;

    }

function withdraw (uint amount) public onlyUser() payable{

        require (msg.sender == users[msg.sender].addr);
        require (amount > 0);
        require (amount <= users[msg.sender].balance);

        msg.sender.transfer(amount);

        users[msg.sender].balance -= amount;
        contractBalance-= amount;
    }

I understand that there will be a function call to withdraw() specifying the amount parameter from the front end using web3.js send() command, but how do I provide the msg.value for the fundContract method from the viewpoint of a Dapp.
Remix allows specifying the value in the message , but I can't find a way to do so for a Dapp.


texts: How can a smart contract run when receiving ether directly, not through a function?

texts:
I have a smart contract with a payable bet() function. When someone sends 1 ether to the bet function, the contract is executed.

I'd like the contract to run the same code when someone sends ether to the address explicitely (as if you're sending ether to someone else), without having to use the function bet().

How do I do this?

Thanks


texts: hwo to make etrc 20 exchangable with ether

texts:
A few days ago i wrote a cryptocurrency.Ik they are lots of vulnabilites and not ready for true deployement.
However iv seen people say in etrc-20 some people dont add this thing where u must pay etheurm to get tokens. Idk how to add this. For more information im using the koven test net.
if u need my code ask in comments. i tried rewatching those tuts but it dint get me far.


texts: If I wanted to create a PoW alrorithm to replace ethash on a private blockchain, how would I tell Parity to use it?


texts: Can I integrate smart contracts in Django application

texts:
I'm new to Blockchain and being from a Microsoft technology stack, a little biased to develop my smart contracts using Solidity. I am using truffle and NodeJS ecosystem. Now I've a Django application interface which needs to be integrated with the smart contracts so need help on the directions moving forward.

I'm working on automating and migrating all transactions of a Logistics system on blockchain. The existing system is on Django - python so need suggestions and guidance on the tech stack, feasibility and limitations.


texts: can parity recovery phrases still be used?

texts:
I have a wallet generated by an old version of parity such that it gave me a recovery phrase, since I have  forgotten the password.  (I think I know the password, but parity disagrees with me).

How do I use the recovery phrase to re-gain access to the wallet?  This must be documented somewhere.  I have tried to track this info down online, and found things like this  which make me nervous.  But I think that's another wallet service.  I also found this.   which seems not to have been answered.

As for "Creating new account via "Recover from phrase"", this screenshot shows that I don't have such an option:


texts: Is it possible to include all the openzeppelin library files on Remix?

texts:
I am trying out Remix as an IDE. However, I'm using the excellent open-zeppelin library for development. Is there any way to include all the files from open-zeppelin in the build path for Remix without pasting them all in there?

I have tried importing a local directory, but since my normal build tool is Truffle, the Remix compiler doesn't pick up the node_modules directory. I tried copying the open-zeppelin directory into the contracts directory, but still my imports won't work. They work if I prefix my paths "./", but I'd rather not do that, since I would have to do it in every single open-zeppelin file.


texts: Deploy pre compiled bytecode using truffle migrations deployer api

texts:
I want to deploy pre-compiled Smart Contract bytecode using Truffle migrations. Specifically, it is the Uniswap V2 Factory contract.
In the Uniswap V2 documentation there is a cliffhanger, where they mention to use:
const UniswapV2FactoryBytecode = require('@uniswap/v2-core/build/UniswapV2Factory.json').bytecode

And then deploy it using Truffle (but do not include an example). However, I cannot get the deployment to work. Here is my migration script:
const UniswapV2FactoryBytecode = require('@uniswap/v2-core/build/UniswapV2Factory.json').bytecode
module.exports = function(_deployer, network, accounts) {
    _deployer.deploy(UniswapV2FactoryBytecode, accounts[0])
};

Note the UniswapV2Factory constructor requires a _feeToSetter address which is why I pass accounts[0] as a parameter.
When I run using truffle migrate --reset the following error is returned:
TypeError: contract.detectNetwork is not a function

Can anyone help point to a solution get this to work?


texts:
I joined Ethereum 's ICO in 2014. But I forgot my password. I have a keystore file but I do not know my password...

So I am thinking of brute force attack on my wallet.

Please tell me the password rules at Ethereum 's ICO. Number of digits, uppercase lowercase, alphameric characters, symbolic character etc.


texts: Metamask false positive error: ERC20 transferFrom tx displays "Exception thrown" error in metamask, but tx confirms fine

texts:
I'm fairly certainly this is due to approvals- that metamask thinks that an error will be thrown because the contract does not have approval to transfer the ERC20- even though the approval tx is currently pending.

My dapp, just like other Dapps, when it needs to get Dai from a user first asks the user to approve the transfer, then there is a second tx where the actual transfer is made. Of course, by the time the second tx has appeared, the approval transaction has not yet confirmed, so metamask thinks it will fail. But, it doesn't, because the approval tx has a lower nonce so will always confirm first.

I don't see other dapps with this problem, any idea what I'm doing wrong? Why can metamask usually take into account a pending tx when trying to figure out if a new tx will fail, but in my case it can't?

See it for yourself, my dapp is public, on kovan. You will need kovan ETH. Please visit harber.io and click on any team. Then press 'Get $100 Test Dai' and wait until confirmed. Then select a rental price and deposit (rental price must be higher than whatever it currently is, deposit must be less than 100) and press 'rent token'. You will see two transactions, the first is the approval for the exact amount of the transfer, and the second is to transfer the Dai. The second transaction, before pressing submit, has the error:

'ALERT: Transaction Error. Exception thrown in contract code.'

But go ahead and submit it, it will work fine.

The front end code which is initiating the two transactions is here.

For reference, here are the two relevant txs on etherscan:

The approval tx: https://kovan.etherscan.io/tx/0x4b80ed0fcf21bcb369a2d60b0ffcbb1677ea61e3ff758b37a696e5fe14cd5786

The transferFrom tx (called via my contract): https://kovan.etherscan.io/tx/0xe4e4b79425c9d639dea20e67ca761d4ca34509380a45920f0f593ee806a60aaf

Both confirm just fine with zero errors. Yet for the second tx, metamask reported said the tx would throw.


texts: What is the Nethereum analog of "web3.version.network"?

texts: I am just getting started with Nethereum and I want to ensure I am connected to the correct network.


texts: Not able to generate java wrapper class from solidity smart contract using truffle

texts:
I'm trying to generate java wrapper class of solidity smart contract using truffle but not getting wrapperclass.java file

Here is an command which i've used to generate abi/Json of that contract

anikett@anikett:~/myproject$ ls -l build/contracts/

total 104
-rw-r--r-- 1 anikett anikett 53703 Oct 16 12:12 Migrations.json
-rw-r--r-- 1 anikett anikett 45796 Oct 16 12:12 Wallet.json

after that used this command which im using for geration of java wrapper class

anikett@anikett:~/myproject$ truffle generate ./build/contracts/Wallot.json -o . -p /home/anikett/Documents/workspace-sts-3.9.9.RELEASE/JavaEthereumConnectionExample/src/main/java/com/ethereum/connect.javaethereum.wrapper


texts:
What I want to achieve is self-destructing token.

For example I'd like to have some updatable TTL value assigned to my token. If TTL is reached the token should be auto-burned.

What are the best possible solutions for such task?

Is such an implementation insecure? What are the good practices?


texts: Test.js Function Event Logs Return Empty Array - Async/Await/Promise/Tronweb Issue

texts:
I'm working on a Tron smart contract and am providing a function in my tests file which emits to an event. When trying to console.log the logs I get an empty array. Is this because of lag for the transaction to hit the shasta network or is there something else I'm overlooking? I am using tronbox test --network shasta.
Here is a bare bones test version of my contract:
pragma solidity >=0.5.0 <0.7.0;

contract TronStack {

    uint public investmentCount;
    mapping (uint => Investment) public investments;

    struct Investment {
        uint id;
        uint amount;
    }

    event InvestmentCreated (
        uint id,
        uint amount
    );

    constructor() public {
    }

    function invest(uint _amount) public {
        investmentCount++;
        investments[investmentCount] = Investment(investmentCount, _amount);
        emit InvestmentCreated(investmentCount, _amount);
    }

}

And here is my js test file:
const TronStack = artifacts.require('./TronStack.sol')
const TronWeb = require('tronweb')

contract('TronStack', (accounts) => {
    let tronstack

    before(async () => {
        tronstack = await TronStack.deployed()
    })

    describe('deployment', async () => {
        it('deploys successfully', async () => {
            const address = await tronstack.address
            assert.notEqual(address, 0x0)
            assert.notEqual(address, '')
            assert.notEqual(address, null)
            assert.notEqual(address, undefined)

            addressTron = tronWeb.address.fromHex(address)
            console.log(addressTron) // returns contract address
        })
    })

    describe('investments', async () => {
        let result, event, investmentCount

        before(async () => {
            result = await tronstack.invest('10000000')
            event = await tronWeb.getEventByTransactionID(result)

            investmentCount = await tronstack.investmentCount()
        })

        it('adds investment', async () => {
            assert.equal(investmentCount, 1)

            console.log(result) // returns tx id
            console.log(event) // returns empty array

            // using a previous tx id prints logs as intended
            oldTX = await tronWeb.getEventByTransactionID('0c960b698ffc889c1c7df81dc2f09eace47d50c73ffc662c2e3fb1671c4515c4')
            console.log(oldTX)

        })
    })

})

The test returns something like this:
  Contract: TronStack
    deployment
TCW4HMVoRKpQUqDhFjxXmMQkd5Hse3JXh4
      ✓ deploys successfully
    investments
047f8548dae22ea85dcd569b888e0ff2deaca1bd23b43460cb5759a736e5c6c7
[]
[
  {
    block: 7796397,
    timestamp: 1599495159000,
    contract: 'TAoE543WH1fVerZRHK5ecsKU2VPckE5mLw',
    name: 'InvestmentCreated',
    transaction: '0c960b698ffc889c1c7df81dc2f09eace47d50c73ffc662c2e3fb1671c4515c4',
    result: { '0': '1', '1': '10000000', amount: '10000000', id: '1' },
    resourceNode: 'solidityNode'
  }
]
      ✓ adds investment (133ms)

  2 passing (956ms)


texts: Best ethereum client for wallet development?

texts: Which ethereum client has the best API + docs when it comes to wallet development? I've used bcoin and lcoin so far and they have an http api. Is there an ethereum client out there with a nice, documented http api?


texts: web3.py transact function giving unknown account error

texts:
I am able to use the web3.py library and i am able to deploy the contract directly using my node in ethereum.

I created my solidity code in remix and copied the abi in the etherum console to deploy the code. I got the address of the contract as well.

My solidity code is as follows.

pragma solidity ^0.4.0;

//For testing use the below data
//123,"wheat","grade1",50

contract bidding {

struct bid {
    string bidderName;
    uint grainId;
    uint bidAmount;
    uint bidTime;
}

mapping (uint => bid) bidInfos;
uint[] public bidIds;

function addBid(
    uint _bidId,
    string _bidderName,
    uint _grainId,
    uint _bidAmount
) public {
    var bid_info = bidInfos[_bidId];
    bid_info.bidderName = _bidderName;
    bid_info.grainId = _grainId;
    bid_info.bidAmount=_bidAmount;
    bid_info.bidTime= now;

    bidIds.push(_bidId) -1;
}

function getallBids() view public returns(uint[]) {
    return bidIds;
}

function getBid(uint _bidId) view public returns (string, uint, uint, uint) {
    return (
        bidInfos[_bidId].bidderName,
        bidInfos[_bidId].grainId,
        bidInfos[_bidId].bidAmount,
        bidInfos[_bidId].bidTime
    );
}

function getbidcount() view public returns (uint) {
    return bidIds.length;
}
}

I deployed in my etherum network and got the address as
In my python i am using the web3 library.

from web3 import Web3, HTTPProvider, IPCProvider, WebsocketProvider
import json
web3 = Web3(IPCProvider())
bid_abi=json.loads('''[{"constant":false,"inputs":[{"name":"_bidId","type":"uint256"},{"name":"_bidderName","type":"string"},{"name":"_grainId","type":"uint256"},{"name":"_bidAmount","type":"uint256"}],"name":"addBid","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"getallBids","outputs":[{"name":"","type":"uint256[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_bidId","type":"uint256"}],"name":"getBid","outputs":[{"name":"","type":"string"},{"name":"","type":"uint256"},{"name":"","type":"uint256"},{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getbidcount","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"bidIds","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"}]''')

contract_bid=web3.eth.contract(abi=bid_abi,address='0xbcd8ffbb0f8a5410194ab5a3badf46caaa693098')

contract_bid.functions.addBid(10,"xyzz",1234,5600).transact()

This is the error i am getting.

  Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "D:\WinPython\python-3.5.4.amd64\lib\site-packages\web3\contract.py", line 1064, in transact
**self.kwargs)
  File "D:\WinPython\python-3.5.4.amd64\lib\site-packages\web3\contract.py", line 1341, in transact_with_contract_function
txn_hash = web3.eth.sendTransaction(transact_transaction)
  File "D:\WinPython\python-3.5.4.amd64\lib\site-packages\web3\eth.py", line 244, in sendTransaction
[transaction],
  File "D:\WinPython\python-3.5.4.amd64\lib\site-packages\web3\manager.py", line 106, in request_blocking
raise ValueError(response["error"])
 ValueError: {'code': -32000, 'message': 'unknown account'}

I am doing a web3.personal.unlockAccount as well. still it is giving same error.
There is only one account associated with my account as well. What am i doing wrong?

how to do the transaction so i can add a new bid from web3 in python and get the transaction hash.


texts: How is a token implemented on ERC20 benefiting from not using Ethers?

texts:
I am aware that there is a lot of documentation on ERC20. However because of all the hype about new tokens it is getting hard to find good material that isn't about ICOs.

I am wondering why are there so many ERC20 based tokens? What is the advantage of using a custom token? To the best of my understanding, the ERC20 tokens are validated and mined by Ethereum full nodes.

Can't all systems built using an ERC20 token just use ETH as a currency for transactions?


texts: Pre populating an Ethereum contract with digital assets

texts:
I would like some advice on what approach with be best to take to achieve the following.

I want to release the contract with around 50,000 digital assets, think of it like pre filling a database with around x number of users. I want to then release a new asset every x amount of minutes, similar to CryptoKitties. Users can then purchase these newly released assets.

The asset may be structured as follows:

ID,
Field 1,
Field 2,
Field 3

Now Im not to worried about the second part, my issue is how I go about pre loading the 50,000 digital assets. Im thinking in terms of gas costs etc as that many records might be expensive.


texts: Connection between nodes crashes when I start mining in private network

texts:
I'm exploring blockchain technology and I want to setup my own private Ethereum network. There are a number of tutorials over the Internet (such as this), but unfortunately I have a problem, when any node starts mining, connection between nodes disappears.

To be concrete, I use 2 Amazon instances (Ubuntu Server 16.04 LTS (HVM), SSD Volume Type, t2.medium (2 vCPUs 2.3 GHz, 4GiB RAM)) and connect to them via ssh from my Windows desktop.
I install geth on both (as described here) and have version 1.8.8-stable-2688dab4:

sudo apt-get install software-properties-common
sudo add-apt-repository -y ppa:ethereum/ethereum
sudo apt-get update
sudo apt-get install ethereum

Also I create directory for ethereum on both instances: /home/ubuntu/eth-root/datadir

After that I create my own genesis file and save it in /home/ubuntu/eth-root/genesis.json on first instance and /home/ubuntu/common_init_files/root_init_result/genesis.json on the second one:

{
  "config": {
    "chainId": 4970521,
    "homesteadBlock": 0,
    "eip155Block": 0,
    "eip158Block": 0
  },
  "alloc"      : {},
  "difficulty" : "0x1000",
  "gasLimit"   : "0xFFFFFFFFFFFFFFFF"
}

After that I define some properties (on both instances) via:

export GETH_COMMON_PROPERTIES="--datadir=/home/ubuntu/eth-root/datadir --networkid 4970521 --rpc --rpcport 8101 --rpccorsdomain \"*\" --rpcaddr 0.0.0.0 --rpcapi admin,db,eth,debug,miner,net,shh,txpool,personal,web3 --port 30303"
export GETH="geth ${GETH_COMMON_PROPERTIES}";

Seems that all is OK, so I init first instance with
$GETH init /home/ubuntu/eth-root/genesis.json; and launch simply with $GETH 2>ethereum.log;

After that I check that shasum of both genesis.json files on both instances are same, init second instance via $GETH init /home/ubuntu/common_init_files/root_init_result/genesis.json; and launch also with $GETH 2>ethereum.log;

I attach to running geth on both instances via $GETH attach and add first instance to the second. I execute admin.nodeInfo.enode on the first, replace [::] via public IP address which I receive from Amazon and add it with admin.addPeer(..) to the second instance. Seems that works, because I can see first instance from the second and vice versa with admin.peers for ~5 minutes.

After that I want to start mining, because I want that my own blockchain actually works. I create account on the first instance with personal.newAccount("0000"), set it as etherbase via miner.setEtherbase(personal.listAccounts[0]) and start mining with single thread with miner.start(1), after that I wait some time (~2 minutes) as first instance generates DAG and after that first instance starts to produce new blocks (as eth.blockNumber constantly increasing), but when I execute eth.blockNumber on the second instance I always receive 0! I try to restore connection by adding first instance as a peer for the second one (same command as above admin.addPeer(..), but now it doesn't help, when I look at ethereum.log I can see error: WARN Synchronisation failed, dropping peer peer=48ed8f5fbb9f3f6c err="retrieved hash chain is invalid"). I attempt to add second instance as a peer for the first one, but it also doesn't help. (I also tried to add peers via --bootnodes flag on startup, but results were the same).

How can I fix this to setup my own working private Ethereum network?


texts: How to access and import presale ether without the json wallet file

texts:
I purchased ether presale.  I have the public key, which shows the amount, and I have a text password I created at the time of purchase.  I do not have a json drop file.  How do I import my wallet? I think I have private key but do not know where to enter it.  Please help?

Thanks


texts: Parity, Web3, Nodejs - Error: Transaction was not mined within 750 seconds, please make sure your transaction was properly sent

texts:
I'm using Parity ( "ropsten" test net), Nodejs and web3js to deploy smart contract from my system. Parity is synchronised in test mode, but when I run below code using Nodejs, it gave me a transaction id "https://ropsten.etherscan.io/tx/0xa229e52224e7200337aa7893fea71c83e79cd5b2b37234a1559d9e6a7512385d", but when I verified this transaction on etherscan ropsten testnet, then I found that transaction not mined by etherscan. Not sure why transaction not moved from my local "Parity" node to etherscan.

Any help would be appreciated.

var Web3 = require('web3');
let fs = require("fs");
var solc = require('solc');

if( typeof Web3.currentProvider !== 'undefined'){
    web3 = new Web3( Web3.currentProvider );
}else{
    web3 = new Web3( new Web3.providers.HttpProvider("http://localhost:8545"));
}

async function deployContract(){

    var address = await web3.eth.getAccounts()
    var contractAdminAddrs = address[2]
    console.log("Contract deployed from: "+contractAdminAddrs);

    var input = {
        //'IERC20.sol': fs.readFileSync('IERC20.sol', 'utf8'),
        //'SafeMath.sol': fs.readFileSync('SafeMath.sol', 'utf8'),
        'Distribution.sol': fs.readFileSync('Distribution.sol', 'utf8')
    };
    let compiledContract = await solc.compile({sources: input}, 1);

    //console.log(compiledContract);
    //return false;

    let abi = compiledContract.contracts['Distribution.sol:Distribution'].interface;
    let bytecode = '0x'+compiledContract.contracts['Distribution.sol:Distribution'].bytecode;

    console.log("Contract Deployment Gas Estimate=")
    var gasEstimate = web3.eth.estimateGas({
        to: contractAdminAddrs,
        data: bytecode
    }).then(console.log)

    let Token = new web3.eth.Contract(JSON.parse(abi));

    console.log("ABI");
    console.log(abi);
    //return false;

    //var gasEstimate = 4500000; //Default gas
    var gas_Estimate = 4500000    //Calculated from above function,used static
    var gasPrice = 30000000000;

    var lms = Token.deploy(
        {data:bytecode,arguments:[contractAdminAddrs]})
        .send({
            from: contractAdminAddrs,
            gas: gas_Estimate,
            gasPrice: gasPrice
        },
        function(error, transactionHash){
            console.log("send function error=")
            console.log(error)

            console.log("transactionHash=")
            console.log(transactionHash)
        })
        .on('error', function(error){
            console.log("contract deploy error=")
            console.log(error)
        })
        .on('transactionHash', function(transactionHash){
            console.log("transactionHash 2nd function=")
            console.log(transactionHash)
        })
        .on('receipt', function(receipt){
            console.log("Receipt=")
            console.log(receipt.contractAddress) // contains the new contract address
        })
        .on('confirmation', function(confirmationNumber, receipt){
            console.log("Confirmation Number=")
            console.log(confirmationNumber)
        })
        .then(function(newContractInstance){
            console.log("New Contract address=")
            console.log(newContractInstance.options.address) // instance with the new contract address
        });

}

//Call function to deploy contract
deployContract()


texts: Etherscan.io How does it get the exchange wallet address for these token addresses?


texts: Is pre 0.5.0 keccak256(a,b) equivalent to post 0.5.0 keccak256(abi.encodePacked(a,b))?

texts:
In pre 0.5.0 Solidity if you wanted to hash a some set of data you would do keccak(a, b, c). Post 0.5.0 keccak only takes 1 arg and it is suggested to use keccak(abi.encodePacked(a,b,c)) instead

But are the two guaranteed to return the same result? I did some quick testing and it seems like they do, but is this something I can rely on?


texts: constant and visibility specifier in solidity

texts:
I am trying to run this code but it throws the errors . Is this possible using visibility specifier and constant once ?

pragma solidity ^0.4.0;
contract C {
    function first(uint a) private constant returns (uint b)
    {
        b= a +1;
    }
}


texts: Instantiating a smart contract in Uniswap using assembly and create2

texts:
I am studying Uniswap source code and there is something I do not understand in this file:
https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/UniswapV2Factory.sol:
This factory can create new pairs (createPair function):
    bytes memory bytecode = type(UniswapV2Pair).creationCode;
    bytes32 salt = keccak256(abi.encodePacked(token0, token1));
    assembly {
        pair := create2(0, add(bytecode, 32), mload(bytecode), salt)
    }

for me, these 4 lines do the same thing than:
pair = new UniswapV2Pair()

I do not understand what they want to do with the 4 lines of codes. Do you have any idea ?
Thanks a lot


texts: Hello I am new to blockchain. I was reading solidity docs and they were continuously repeating the word "literal", what does this word mean? Please elaborate.


texts: Why are contracts limited to only the previous 256 block hashes?

texts:
Why are contracts limited to only the previous 256 block hashes using the BLOCKHASH opcode (and corresponding functions in Solidity and Serpent)?

Why does another contract, such as this, need to be used to get block hashes more than 256 blocks ago?  Also, how was the 256 limit determined and are there any plans on adjusting it?  (Increasing it would still preserve backwards compatibility.)


texts:
I have already deployed my smart contract on Ropsten network for testing using truffle suite. The command line I used was:

truffle deploy --network ropsten

Now, I have made some changes to my contract and again want to deploy it for testing. Do I just run the above command once again or is there some other way where we first destruct the existing contract and then redeploy it?

Thanks.


texts: Ethereum transaction taking way too long time

texts: I have generated and (aparently) successively transferred some Ether from an exchange to my etherwallet 24hs ago... now still the eths never arrived on my wallet... the Exchange shows transaction success showing "OUTPUT TRANSACTION HASH" ok and all... Can someone elaborate? I have notice that other exchanges such as Polo and CoinBase are also having delay problems with transactions using the Ethereum network... Anyway to check wigo, and/or get an idea to when this issue maybe resolved? Thx P.S. I need to make a transaction using the eths... that at the moment are on air...


texts: How do I import from / install OpenZeppelin properly?

texts: I'm a newb dev and want to play with smart contracts, and was trying to figure this out. Ive installed truffle and openzeppelin, everything seems to check out, but in Mist I still get an error when I try to import Math.sol saying it can't be found, what do I do?


texts: Can anyone explain how bytes memory can be converted to address type in solidity

texts:
when I am using below function to convert bytes memory to address, this is working fine.

Suppose input to the function is 0X0000000000000000000000004af3246b4fff356261136f113411cb187134D675

I am getting the output 0x4af3246b4fff356261136f113411cb187134D675

    function bytesToAddress(bytes memory bys) public pure returns (address addr) {

        assembly {
             addr := mload(add(add(bys, 32), 0))
       }
    }

Can, anyone explain me, what actually happening ?


texts: Is it possible to create a frontend web app that connect to an Ethereum contract for read only without users having to have metamask?

texts:
I would like to create a web front end with as less friction as possible for new users.
The app would be a kind of explorer with all calls to blockchain as read only to getter functions.
So is there a way I can use ethers.js (or web3) so that users are not forced to have metamask when the functions called by the front end don't need to sign a transaction?
In ethers.js it seems I can replace the signer parameter with the provider parameter but it still requires users to have installed metamask. On the contrary with bitcoin explorers we don't need anything like metamask to read only the blockchain, is it different for ethereum and all apps have to make sure their users have an equivalent to metamask installed?
Best regards


texts: Need some feedback/critique on a smart contract that allows anyone to send Eth and split it (50:50) with two other accounts

texts:
pragma solidity 0.8.1;

contract splitFunds {
  mapping(address => uint) public beneficiaryBalances;

  address[2] public beneficiaryList;

  event LogReceived(address sender, uint amount);
  event LogWithdrawal(address beneficiary, uint amount);

  function splitFunds(address addressA, address addressB,) payable(addressA, addressB,) public

    function pay()
    public
    payable
    returns(bool success)
  {
    if(msg.value==0) throw;

    uint forth = msg.value 1/2;

    LogReceived(msg.sender, msg.value);
    return true;
  }
    function Modulo() view public returns (uint)
    {
        uint answer = 50 % 50 ;
        return answer;
    }

  function withdraw(uint amount)
    public
    returns(bool success)
  {
   if(!msg.sender.send(amount)) throw;
   msg.sender.transfer(amount);

   emit LogWithdrawal(msg.sender, amount);
   return true;
  }

}


texts: How can I set the gas price of a transaction initiated by a contract?

texts: I am writing a contract that will interact with another contract: contract A will call a function defined by contract B. Is it possible to set the gas price that contract A is willing to pay when initiating the transaction that will call the function defined by contract B?


texts:
Can someone explain in layman term, why the transaction needs to be signed and the role of public key, private key in transaction signing process.
From what I have read so far:

When user creates a new Account, specifies passphrase. Privatekey is
generated and stored in keystore file. (encrypted using passphrase).
When sending transaction, Passphrase is used to decrypt the keystore and retrieve private key.
Private key is used to sign transaction. Signed transaction is published by the node.
Receiving node uses public key (how other nodes get public key?) to verify
signature. If valid, transaction is processed.

Pls let me know if above understanding is correct and help to understand questions raised in the workflow.


texts: I need help depositing my money into my kraken account

texts: i was wodering how to exactly deposit money into my kraken account. I am on the part where I pick my deposit method, and i click on the amount i want and shows me a address and other things like that, and at this point im stuck, i have all my information on my bank and whatnot,but now im just stuck. anything would help a lot


texts: Difference between transfer to ethereum account or to smart contract?

texts:
Is there a difference between sending ether to a user account or to a smart contract. E.g.:

contract ThisIsAContract{
    function()
        public
        payable
    {}
}

Now I call (pseudocode)

address(0x0).transfer(payout);

and also

address(ThisIsAContract.address).transfer(payout);

Are both okay and do they act the same?


texts:
Since today ETH transaction fees become so high, I (and possibly many people) want to save money by reducing these fees.
I notice that transaction fees are cheeper in some DEXs compared to those of the others, even if you want to swap exactly same amount of token. (For example, Uniswap's transaction fee is much cheeper than that of 1 inch.)
Why such kind of things happen? And what determines the transaction fee?
If I can know the background, I believe it would be helpful for finding best DEXs saving our token.


texts:
I'm getting the following error:

  Data location must be "calldata" for parameter in external function, but "memory" was given.

for the following function:

    function _registerAirline(address addr, string memory name)
        external
        requireIsOperational
    {
        require(!airlines[addr].isRegistered, "Airline is already registered");

        airlines[addr] = Airline({
            name: name,
            isFunded: false,
            isRegistered: true
        });

        multiSig.push(addr);
        emit AirlineRegistered(
            airlines[addr].name,
            airlines[addr].isFunded,
            airlines[addr].isRegistered
        );
    }

But, when I change the string memory name to string calldata name and compile, I get an error:

ParserError: Expected ',' but got identifier
function _registerAirline(address addr, bytes calldata name)
                                                       ^--^


texts: How can I make other people's account to do ether transactions with smart contract?

texts: I was making a smart contract which involves people to buy tokens in exchange of ether they send. It works fine in testrpc as all accounts are unlocked, but how do I do it for actual accounts in main network using web3 in nodejs. What fields would be required to invoke these payable functionalities of smartcontract except the wallet address ofcourse? Any code snippets or examples? Any help would be appreciated. Thanks.


texts: What is the function selector of the fallback function?

texts:
The function selector are the first four bytes of the keccak256 hash of the function signature. What is the signature of the fallback function? It neither has a name nor any inputs.
If there is no real signature there have to be at least a custom function selector (some fixed 4 bytes reserved for the fallback function).