texts: Can a child block have an earlier timestamp than the parent block?

texts:
From From EIP 2, the Homestead difficulty adjustment algorithm is:

    block_diff = parent_diff + parent_diff // 2048 *
      max(1 - (block_timestamp - parent_timestamp) // 10, -99) +
      int(2**((block.number // 100000) - 2))

  where // is the integer division operator, eg. 6 // 2 = 3, 7 // 2 = 3, 8 // 2 = 4.

Due to differences in the clock settings on different miner's computers, can block_timestamp be before parent_timestamp?

And if block_timestamp CANNOT be before parent_timestamp, how are differences in the clock settings on different miner's computers taken into account?

EDIT June 12 2016 I've moved the second question above into How do Ethereum mining nodes maintain a time consistent with the network?

This question was prompted by the question How does the Ethereum Homestead difficulty adjustment algorithm work?, which was prompted by the question What was the first block mined with Homestead?

Other related Q&As:

How is the Mining Difficulty calculated on Ethereum?
What is the measured distribution of block times since Homestead?


texts: How to find out if a wallet (an address) contains a token from a contract using web3js?

texts: Is this possible with and without knowing the private key of the wallet.


texts: Out of gas exception when calculating Keccak256 inline solidity assembly

texts:
I am trying to write a simple function which should return me Keccak256 of an incoming uint using Solidity inline assembly function, however it returns me out of gas exception when trying to execute the function on remix, can someone help me fix the issue here ?

   pragma solidity ^0.4.18;

contract HashedTimelock {

        address sender = 0xca35b7d915458ef540ade6068dfe2f44e8fa733c;
        address receiver = 0x14723a09acff6d2a60dcdf7aa4aff308fddc160c;
        bytes32 hashlock = 0x731dc163f73d31d8c68f9917ce4ff967753939f70432973c04fd2c2a48148607; // sha-2 sha256 hash
        uint  timelock = 1522660821; // UNIX timestamp seconds - locked UNTIL this time

   function HashedTimelock() payable{}

    function withdraw(bytes32 _preimage)
        external returns(bytes32 sample)
    {
        uint  timenow = now;
        assembly {
            // first check if the pre image matches with internal hashlockMatches
            // check the timelock
            // use selfdestruct to transfer the funds
            if eq(1,lt(timenow, sload(timelock_slot))){
               let selfptr := mload(add(_preimage, 0x20))
               sample := keccak256(selfptr, 32)

            }
        }

    }

}


texts: Possible to replace entire balance map in single transaction?

texts:
I know about gas limits per block, but I can't wrap my head around this problem right now.

If I have a token contract that needs to update the balance of every address, is it possible to have a function create a new balance map with all of the new balances? This seems like a ton of data to manipulate in a single transaction...

If I have a balance map with say 1,000,000 addresses, how much data would this be represented in kB? How do you calculate it? If you can't replace the entire balance map because of gas limits, how do you go about this?


texts: address.(send|transfer), recipient not receiving

texts:
In a Solidity contract I am using address.send() and address.transfer() to send money to a recipient. When I execute that function the balance of the contract gets deducted but the recipient address never receives the funds in their account.

What is going wrong and how I do I debug / fix? I am new to Ethereum, so baby steps please :)

Thanks

UPDATE:

I am using testrpc and it would appear that I don't see a transaction for that amount on the console output. All I am seeing on the blockchain is the transaction to call my contract function that contains address.send(). Why is this?

UPDATE: Contract as requested

pragma solidity ^0.4.11;
// We have to specify what version of compiler this code will compile with

contract Hackathon {

  struct Entry {
    bytes32 name;
    uint votes;
    address wallet;
  }

  Entry[] public entries;
  address winner;

  function AddEth () payable {}

  /* mapping field below is equivalent to an associative array or hash.
  The key of the mapping is candidate name stored as type bytes32 and value is
  an unsigned integer to store the vote count
  */

  mapping (bytes32 => uint8) public votesReceived;

  /* Solidity doesn't let you pass in an array of strings in the constructor (yet).
  We will use an array of bytes32 instead to store the list of candidates
  */

  /* This is the constructor which will be called once when you
  deploy the contract to the blockchain. When we deploy the contract,
  we will pass an array of candidates who will be contesting in the election
  */
  function Hackathon() {
  }

  // This function returns the total votes a candidate has received so far
  function totalVotesFor(bytes32 candidate) returns (uint8) {
    if (validCandidate(candidate) == false) throw;
    return votesReceived[candidate];
  }

  // This function increments the vote count for the specified candidate. This
  // is equivalent to casting a vote
  function voteForCandidate(bytes32 candidate) {
    if (validCandidate(candidate) == false) throw;
    votesReceived[candidate] += 1;
  }

  function validCandidate(bytes32 candidate) returns (bool) {
    for(uint i = 0; i < entries.length; i++) {
      if (entries[i].name == candidate) {
        return true;
      }
    }
    return false;
  }

  function getWinner() returns (bytes32, uint256, address) {

    bytes32 winnerName;
    uint winningVoteCount = 0;

    for (uint p = 0; p < entries.length; p++) {
        if (votesReceived[entries[p].name] > winningVoteCount) {
            winningVoteCount = votesReceived[entries[p].name];
            winnerName = entries[p].name;
            winner = entries[p].wallet;
        }
    }

    return (winnerName, winningVoteCount, winner);
  }

  function payWinner() returns (bool) {

    winner.transfer(23);

    return true;
  }

  function addEntry(bytes32 name, address wallet) returns (uint256) {

    Entry memory tmpEntry;
    tmpEntry.name = name;
    tmpEntry.wallet = wallet;

    return entries.push(tmpEntry);
  }

  function getEntriesCount() returns (uint256) {

    return entries.length;
  }

  function getEntry(uint index) returns (bytes32, uint, address) {

    return (entries[index].name, votesReceived[entries[index].name], entries[index].wallet);
  }
}


texts:
The following transaction failed but I still lost ether also fee was charged

trx :0xa4620f966b385c68eabb19e94e286bd21c934c7b194de6d60faba3a4ea3e680e

Thanks
Bravocc


texts: ether payout of bitstamp on blockchain failed in the system of bitstamp I only see the info wthraw failed and the support means etherscan also nothing to see what should I do?


texts: How to connect to mainnet on website with web3js?

texts:
I have been searching and seeing similar questions but I don't really understand the answer. I have a very simple node.js application that does not involve smart contacts. All I want to do is check the balance of an ethereum address. I see this in the web3js documentation

web3.setProvider(new web3.providers.HttpProvider('http://localhost:8545'));

but that is if I'm running a node on my server, which has a bunch of security issues on its own. Is there a provider I can use for mainnet to just check balances? If not why not?


texts:
If I understand correctly, A meta-transaction pattern is a like a middleware software between the client and the blockchain that pays for the transaction fees.

If I sign a transaction and send it to the middleware software, is my transaction signature already contains information like (from: account to charge with transaction fees). How does this really work without compromising too much decentralization.


texts: How to recreate a HexaryTrie from a saved database

texts:
I am trying to create a HexaryTrie from the database that the trie writes to.

Here is my Code:

from trie import (
    HexaryTrie,
)

db = {}
trie1 = HexaryTrie(db)

trie1[b'deadbeef'] = b'deadbeef'
...

trie2 = HexaryTrie(db)

print(trie1.root_hash)
print(trie2.root_hash)
# ^ these print different root hashes :(

I saw in py-trie, that the HexaryTrie constructor is:

def __init__(self, db, root_hash=BLANK_NODE_HASH, prune=False):
    self.db = db
    validate_is_bytes(root_hash)
    self.root_hash = root_hash
    self.is_pruning = prune

Is there a way to use the db that is being created to "re"-create the trie?

Thank you in advance :)


texts:
I'm on a 2013 Macbook Pro / 16 GB ram / 512 SSD / 2.3 GHz

I just transferred 3 ETH from my poloniex account to the Ethereum Wallet on my local machine. The thing is, the entire blockchain hasn't finished downloading (stuck at 50% since 1.5 hours) and the balance ether is not reflecting in my local wallet. The exchange confirms that the transfer is accepted and confirmed.

I have quit the entire blockchain download and resorted to a --fast and --cache=2048 but even that is going very slowly. Sync first failed with and then imported new chain segment and started downloading slowly again.

At the time of posting, the last log reads:

  WARN [06-20|11:15:53] Synchronisation failed, retrying         err="block body download canceled (requested)"

I'm a complete newb to crypto and this is my first attempt at transferring funds from an exchange to my personal wallet. What can I do to expedite this process / am I doing something wrong? I'm a little worried.

ETA

This is what the task log is reflecting now:

  WARN [06-20|11:20:09] Synchronisation failed, retrying         err="block header download canceled (requested)"
  WARN [06-20|11:23:41] Synchronisation failed, retrying         err="receipt download canceled (requested)"


texts: How to build or install the haskell client EthereumH?

texts:
I tried to build EthereumH from this github resource: https://github.com/jamshidh/ethereumH

I installed google's git-repo and tried to install at as described in the README. It failes with the following missing repository (404):

remote: Repository not found.
fatal: Authentication failed for 'https://github.com/kjameslubin/hserver-eth/'

I then tried to skip the umbrella repository, and tried to install the ethereum-client-haskel with cabal: https://github.com/jamshidh/ethereum-client-haskell

But that's a mess, too:

 $ cabal install ethereum-client-haskell
Resolving dependencies...
cabal: Could not resolve dependencies:
trying: ethereum-client-haskell-0.0.4 (user goal)
trying: base-4.8.2.0/installed-0d6... (dependency of ethereum-client-haskell-0.0.4)
trying: cmdargs-0.10.14 (dependency of ethereum-client-haskell-0.0.4)
trying: process-1.2.3.0/installed-78f... (dependency of cmdargs-0.10.14)
next goal: haskoin (dependency of ethereum-client-haskell-0.0.4)
rejecting: haskoin-0.1.0.2, 0.1.0.1, 0.1.0 (conflict: process => deepseq==1.4.1.1/installed-614..., haskoin => deepseq>=1.3 && <1.4)
rejecting: haskoin-0.0.2.1, 0.0.2 (conflict: base==4.8.2.0/installed-0d6..., haskoin => base>=4.6 && <4.7)
Dependency tree exhaustively searched.

I also figured out that this project might be integrated in Consensys / Blockapps, but only found an empty repository: https://github.com/blockapps/ethereumH

Is this project still alive? How to build or install the haskell client EthereumH on a Linux system?


texts: Not able to fetch custom token after mint from Infura

texts:
I am using web3j library with an Infura Websocket connection. I set up a subscribe method where I listen to transfer events of my custom ERC20 Token. When a transfer event occurs on the blockchain I get the information in the subscribe body and send it to my eventListener. In my eventListener I try to fetch the details of the Token from the Blockchain (over the same Infura websocket connection)

Publisher.java

web3j.logsNotifications(List.of(customToken.getContractAddress()), List.of(EventEncoder.encode(CustomToken.TRANSFER_EVENT)))
                        .subscribe(logNotification -> {
                            Log transferEventLog = logNotification.getParams().getResult();
                            publisher.publishEvent(transferEventLog);
                        }, throwable -> {
                            logger.error("Error in subscription", throwable);
                        }, () -> {
                            logger.info("Complete transfer event subscription");
                        });

Listener.java

public void transferEventListener(Log transferEvent) {
        // code to parse log -> to get id of token
        Tuple2<String, BigInteger> response= customToken._tokens(id).send();

        // Further code to handle response
}

The call in my listener always fails with Exception: Request with id # timed out
and then my Websocket connection gets closed.

If I make the same request to tokens which are minted in the past, everything works as expected!

Is it generally possible to fetch a custom token from Infura directly after they are mined? What I am doing wrong here?


texts:
I am looking for clarity on transaction tree structure. Below I have listed my understanding

If I am not wrong the state changes are tracked in a single state tree.
Each block has a state root hash pointing to the root having the state of the accounts taking part in the set of transactions to that block
So as the blocks keep on adding (i.e. there are changes in state of accounts)  this state tree grows
But how about the transaction tree
Are the transaction root hash present in a block pointing to individual tree roots or again its a single tree like state tree (i.e. it points to various root levels)
To highlight this difference I have created two diagrams for state and transaction trees.
So what I am trying to say is all the blocks refer to a common state tree. But each block is having its own transaction tree
Please share your views and correct me where you feel I am wrong

  State Tree

  Transaction Tree


texts: Calling smart contract functions and submitting transacions in BACK-END in high level

texts: I have read some references to create ethereum transactions by a BACK-END server, all in low level, for example, requiring that I control the nonce by myself. Are there safe ways to avoid this control be assuming by default that every call can increment the nonce by one and there is no parallelism? What libs allows me that control and works in a more hogh-level way?


texts:
We have a contract as follows:

pragma solidity 0.4.23;

    contract RFID {

        struct StateStruct {
            bytes32 description;
            mapping(bytes32 => bytes32) sub_state;
        }

        struct ObjectStruct {
            StateStruct state;
            address owner;
            bool isObject;
        }

        mapping(bytes32 => ObjectStruct) objectStructs;
        bytes32[] public objectList;
        //uint256 public number_of_sub_states = 3;

        event LogNewObject(address sender, bytes32 id, bytes32 sub_states_types, bytes32 sub_states_values, address owner);
        event LogChangeObjectState(address sender, bytes32 uid, bytes32 newState);
        event LogChangeObjectOwner(address sender, bytes32 uid, address newOwner);

        function isObject(bytes32 _id) public view returns(bool isIndeed) {
            return objectStructs[_id].isObject;
        }

        function getObjectCount() public view returns(uint count) {
            return objectList.length;
        }

        /*function setArraySize(uint256 _number_of_sub_states) public {

            number_of_sub_states = _number_of_sub_states;

        }

        function getArraySize() view public returns (uint256) {
           return number_of_sub_states;
        }*/

        function newObject(bytes32 _id, uint256 number_of_sub_states, bytes32[10] sub_states_types, bytes32[10] sub_states_values, address _owner) public returns(bool success) {
            require(!isObject(_id));

            uint256 counter=0;
            for(counter; counter < number_of_sub_states; counter++) {

                objectStructs[_id].state.sub_state[sub_states_types[counter]] = sub_states_values[counter];

                emit LogNewObject(msg.sender, _id, sub_states_types[counter], bytes32(sub_states_values[counter]), _owner);

            }

            objectStructs[_id].owner = _owner;
            objectStructs[_id].isObject = true;

            objectList.push(_id);

            return true;
        }

        function changeObjectState(bytes32 _id, bytes32 _newState) public returns(bool success) {
            require(isObject(_id));
            //objectStructs[_id].location = _newState;
            objectStructs[_id].state = StateStruct(_newState);
            emit LogChangeObjectState(msg.sender, _id, _newState);
            return true;
        }

        function changeObjectOwner(bytes32 _uid, address _newOwner) public returns(bool success) {
            require(isObject(_uid));
            objectStructs[_uid].owner = _newOwner;
            emit LogChangeObjectOwner(msg.sender, _uid, _newOwner);
            return true;
        }

    }

When, I call function newObject in remix, I receive the following error:

Invoke newObject in remix using related text box : 100, 3,
 [bytes32("location"),bytes32("price"),bytes32("sold")], [bytes32("Paris"),bytes32("50"),bytes32("yes")], address(0xE07b6e5a2026CC916A4E2Beb03767ae0ED6af773)

ERROR : error encoding arguments syntax error unexpected token b in JSON at position 12.

What is the reason of this error ?

IMPORTANT NOTE : I edited my question regarding to the answer of user Jesse Busman.


texts: Does the new Solidity version allow returning an array of struct?

texts:
All of the posts I've seen say that Solidity doesn't let you return an array struct, but when I do the following, no error is thrown and I can, in fact, get the array of struct in the front end:
pragma solidity >=0.7.0 <0.9.0;

struct SomeStruct {
   string name;
   uint number;
}

mapping(address => SomeStruct[]) database

function getAll() public view returns (SomeStruct[] memory) {
     SomeStruct[] memory structArray = database[msg.sender];
     require(structArray.length > 0, "is empty");

     return structArray;
}

Is the newer version of Solidity allowing this?
The reason I'm investigating this is because the returned array is occasionally missing an element and I can't seem to pinpoint whether this is caused by above code or not.
** Update **
mapping (address => File[]) database;
mapping (address => uint) public index;

struct File {
    string hashString;
    string date;
    bool isActive;
    uint index;
    uint32 size;
    string name;
}

function setFile(string memory _hashString, string memory date, uint32 _size, string memory _name) public {
    uint fileIndex = index[msg.sender];

    File memory newFile;
    newFile.hashString = _hashString;
    newFile.date = date;
    newFile.isActive = true;
    newFile.index = fileIndex;
    newFile.size = _size;
    newFile.name = _name;

    database[msg.sender].push(newFile);

    fileIndex ++;
    index[msg.sender] = fileIndex;
}

function getAllFiles() public view returns (File[] memory) {
    File[] memory files = database[msg.sender];
    require(files.length > 0, "There are currently no files");

    return files;
}


texts: Could the parity-ethereum client incorporate doing range proofs in the ethereum blockchain?

texts:
I want to be able to prove that I have stored a number that is in the range of a minimum and maximum value, (a range proof) without revealing the number, and put the value into the ethereum blockchain, so that it can be verified by anyone.

There's a project in the Rust language called bulletproof located here: https://github.com/dalek-cryptography/bulletproofs , could it be added to the client to do this?

How difficult would it be to add this feature? I'm an experienced Java programmer, and I'd rather work in Java, but I guess I can learn Rust!


texts: Retrieve Uniswap tx data in my solidity smart contract

texts:
As the title says, I have my Solidity smart contract and I am trying to import in ti some public data from the Uniswap contract.
In particular I would like to have the tx data stored in my contract (let's say the latest 10 tx).
I don't want to do this using web3.js interface, but I would like this to happen within my contract.
I was thinking of using Oraclize somehow (I never used this).
Would it be possible to query a deployed smart contract and get past tx data?
What would be the best way?


texts: I've geth node running on my local and I need to find out http url and ethereum url to deploy dapp on Mix IDE. Can any one please help and tell where to find these two parameters ?


texts: Structs giving error while creating nft on ropsten

texts:
I am trying to create 10 random nfts with different supplies using solidity version 6 and remix ide.  However I keep getting the following errors:

contracts/bullrun_cards.sol:29:16: TypeError: Type struct MyNFT.Cards
memory is not implicitly convertible to expected type struct
MyNFT.Cards storage ref[] storage ref. card = Cards({supply:_supply,
description:_desc,card_id:newNftTokenId});
^--------------------------------------------------------------^
contracts/bullrun_cards.sol:30:35: TypeError: Type struct MyNFT.Cards
storage ref[] storage ref is not implicitly convertible to expected
type struct MyNFT.Cards storage ref. allCards[newNftTokenId-1]=card;
contracts/bullrun_cards.sol:31:15: TypeError: Integer constant
expected. Cards[newNftTokenId-1].push(card); ^-------------^

My code is as follows:
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.12;

import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/solc-0.6/contracts/token/ERC721/ERC721.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/solc-0.6/contracts/utils/Counters.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/solc-0.6/contracts/access/Ownable.sol";

contract MyNFT is ERC721, Ownable {

    using Counters for Counters.Counter;
    Counters.Counter private _tokenIds; //Counter is a struct in the Counters library
    uint constant total_supply =7777;

    constructor() ERC721("MyNFT", "MNFT") public {}

    struct Cards{
        uint supply;
        string description;
        uint card_id;
    }

    Cards[] public card;
    mapping(uint =>Cards)public allCards;

    function createCard(uint _supply, string memory _desc) public returns(uint){
        assert(_supply<total_supply);
        _tokenIds.increment();
        uint256 newNftTokenId = _tokenIds.current();
        card = Cards({supply:_supply, description:_desc,card_id:newNftTokenId});
        allCards[newNftTokenId-1]=card;
        Cards[newNftTokenId-1].push(card);

    }

    function mintToken( uint _s, string memory _d,  string memory _tokenURI) public onlyOwner
    {
        uint newid=createCard(_s, _d);
        address _address = msg.sender;
        _safeMint(_address, newid);
        _setTokenURI(newid, _tokenURI);

    }
}

please kindly help me in resolving this issue


texts: How are ethers in the DAO contract transferred to the project?

texts:
If a proposal is approved, how are ethers in the DAO contract transferred to the project?

How does the DAO contract work?


texts: Return code and messages from contract methods

texts:
Suppose, we have an election contract that selects a candidate, based on highest votes, among a set of candidates. This contract can be expected to check if a voter tries to vote more than once.

An implementation of such a check should ideally respond with an error message should the check fail. In the API development world, a JSON message for the error encountered would be the way to go. However, if the same approach was used for a contract, I would imagine that, a fair share of expense would be on building and returning that JSON object.

Another option could be to return a simple JSON object in case of success as {'r' : '0x00', 'resp' : { ... } } and failure as {'r' :0x01}. A wrapper around a web3.js implementation could translate the 0x01 into something more verbose.

Other thoughts?


texts: How do I know my gemini.com's wallet's public key?

texts: Can I know my gemini.com's wallet's public key? gemini.com is an exchange which deals in BTC and ETH. Thank you.


texts:
my question is simple and I want to know if there is a possibility to achieve something like this. I have two contracts, one inherit from the other; I want to access to a method of the child contract from the parent contract, i have clear how to do it in the other way (from child to parent).

Here is more clear:

contract A {

  function doSomethingA() {
   // Here I want to execute doSomethingB();
  }

}

contract B is A {

  function doSomethingB() {
    // Here is what I want to execute from A
  }

}


texts: Where can I find transactions per second statistics?

texts:
A few days ago Vitalik claimed Ethereum was doing 8 transactions per second. The tweet linked to Etherchain, which doesn't seem to have a transactions per second graph.

Where can I find an Ethereum transactions per second graph over time?


texts:
When I go to https://etherscan.io/ens, and then go to the "More" menu, and from there the "ENS Events" menus, all of the events listed are more than 320 days old.

Is there a way to get recent events on Etherscan?

Thanks.
Robert


texts: New Developer - Should I default as many functions as possible to private or internal?

texts:
Would it be good practice to make as many functions as possible private or internal?

With a lot of the recent hacks it seems to be the hackers are getting in through calling functions in unexpected, roundabout ways that isn't always clear to the developer when they publish the code. It seems like if a function can be private or internal it would help.


texts: Modifiers: can I pass an array or specify that not all of them have to pass, but one is enough (OR functionality instead of AND)

texts:
Say I want to restrict a function to only authors and editors. And later on, I want to restrict another function to authors and contributors only.

So ideally, I would add a modifier like this:

pragma solidity ^0.4.19;

contract Foo
{
    modifier ifHasOneOf(uint[] roles) {
        for (uint i=0; i < roles.length; i++) {
            if (getRoleForUser(msg.sender) == roles[i]) {
                _;
            }
        }
    }

    function A() public ifHasOneOf([UserRoles.AUTHOR, UserRoles.EDITOR]) {
        // ...
    }

    function B() public ifHasOneOf([UserRoles.AUTHOR, UserRoles.CONTRIBUTOR]) {
        // ...
    }
}

But then I get into dynamic vs fixed size array trouble.
Then I was thinking if there may be a way to do it like this:

pragma solidity ^0.4.19;

contract Foo
{
    modifier ifHasRole(uint role) {
        if (getRoleForUser(msg.sender) == role) {
            _;
        }
    }

    function A() public ifHasRole(UserRoles.AUTHOR) ifHasRole(UserRoles.EDITOR) {
        // ...
    }

    function B() public ifHasRole(UserRoles.AUTHOR) ifHasRole(UserRoles.CONTRIBUTOR) {
        // ...
    }
}

But then they both have to comply, and having only one of two roles is enough.

What is the best take on this?


texts: Uniswap V2 smart contract keeps getting reverted in JS

texts:
I'm trying to swap tokens using Uniswap v2 interface.
The code of the contract is here.
I'm able to deposit Eth to the contract and but I'm not able to invoke the swapEthForTokenWithUniswap() successfully through javascript.
const swap = async() => {
    const res = await defitry.methods.swapEthForTokenWithUniswap(web3.utils.toWei('0.1', 'ether'))
        .send({from:acc.address,
               gas: 100000})
    console.log(res)
}

The transaction keeps reverting but i can call the function and swap using the writeContract tab on etherscan. I keep getting Object.TransactionRevertedWithoutReasonError


texts: metamask fails to be enable on the ethjs examples

texts: I enabled the metamask by uncommenting the section regarding metamask on ethjs examples from Github but they were no connection and examples seem not been deployed. I am wondering if there is something extra that need to be added in order to connect with metamask. Examples work with uncommented section, meaning the metamask section was not uncommented, but once you enable metamask nothing work. Need help on this matter.


texts: how is it possible to send 5 successful, consecutive transactions at the same time?

texts: I just witnessed something amazing that I didn't think was possible before. I was under the assumption if that you try to submit consecutive transactions, the latest transaction with the highest nonce would override the older transactions, but that doesn't appear to be the case here. This guy sent 5 txs and all 5 of them were successful consecutively. How is this possible?


texts: What is the gas limit for a fallback function called when the method does not exist?

texts: According to the docs a non matching function identifier will trigger the fallback function. So what happens if someone calls my contract with "thisMethodDoesntExist()", would the fallback have a limit of 2300 like when it is triggered with send / transfer, or will it have gas from by the calling method like .call.value?


texts: How many addresses did Ethereum have when it launched? In other words, how many pre-sale addresses are there?


texts: Transfer function not working properly with calculations

texts:
function payWorker1(address schoolId) public payable returns(bool){
        require(Schools[schoolId].moneySent == false);
        require(Schools[schoolId].verified == true);
        Schools[schoolId].accountCaterar.transfer(Schools[schoolId].amountRequired*(caterar/100));
        Schools[schoolId].accountTransporter.transfer(Schools[schoolId].amountRequired*(transporter/100));
        Schools[schoolId].accountSupplier.transfer(Schools[schoolId].amountRequired*(materialSupplier/100));
        Schools[schoolId].moneySent = true;
        return true;
    }

But works fine when I just transfer to one account and without calculation. And function works properly just the amount is not transferred from the contract.


texts: IPFS. Add a directory recursively with an HTTP api

texts:
Is there an HTTP api equivalent of doing:

ipfs add -r resources/public

where resources/public is a directory with a static website (index.html in the root, css, js etc).

Doing:

 curl -F file=resources/public/index.html "http://$IPFS_HOST:5001/api/v0/add?recursive=true&wrap-with-directory=true"

Will only upload one file:

{"Name":"index.html","Hash":"QmZzbCaCPMEGJBLv7DJCDD2mvgkrvTg78MXYt7cPrQhge6","Size":"1255"}
{"Name":"","Hash":"QmdAGnATEQ1VoytC8L9h5nNepmiZCXv61ob49Dpz5nZVGf","Size":"1312"}


texts: Hard vs Soft Hierarchical Address Derivation

texts:
I'm using parity as node/JSONRPC and I'm generating a HD wallet with it.
Basically I have one address and, according to the Parity documentation, I can generate a new address with this command:

parity_deriveAddressIndex

The documentation says:

  Derive new address from given account address using hierarchical
  derivation (sequence of 32-bit integer indices).

It takes the followint Parameters:

Address - Account address to export.
String - Password to the account.
Array - Hierarchical derivation sequence of index and type (soft or hard). E.g. [{index:1,type:"hard"},{index:2,type:"soft"}].
Boolean - Flag indicating if the account should be saved.

I am a bit confused with the third paremeter: what is the difference between using soft and hard hierarchical derivations?


texts: Is geth command line and mist Wallet UI console the same thing?

texts:
In mist browser, I can open Develop | Toggle Developer Tools | Wallet UI and go to the console tab. I can type in all sorts of commands here that control the browser. For example, I can remove unneeded contracts from the watch contract screen with CustomContracts().find().fetch() and then remove.

Question: is the console command line in Mist the same command line I get when I start geth in a terminal window?


texts: Same contract spending different amount of gas on its creation

texts:
I'm developing a contract and when I try to test it on Remix, sometimes I can create it, sometimes not.

  creation of ContractName errored: transaction execution failed

It seems that the environment requires a huge amount of gas to execute this creation.

And no matter how I increase the Gas Limit it is never enough.

The funny stuff is that sometimes the very same contract (with no change in its code) can be created without any problem.

There's also a curious fact that when I take a function off that contract it always require a non-infinite amount of gas on its creation:

function Redeem(address account, uint amount) public onlyOwner returns(uint) {
    require(_yield[account] >= amount, "Not enought funds.");

    _yield[account] -= amount;
    return amount;
}

Does anybody has a reasonable explanation for all that. I appreciate very much!

EDIT:

I took some time evaluating the code, and I realized one thing:

There are the contract A and the contract B.
A has a function that creates an instance of B.

function AddB(Someinterface x) public onlyOwner {
    require(address(_bs[x.Name()]) == 0x0, "B for this name already exists.");
    require(keccak256(abi.encodePacked(x.Name())) != keccak256(abi.encodePacked("text")), "text name is reserved.");

    _bs[x.Name()] = B(new B(x));
}

When I try to deploy A, I have the problem I told above.
I can always deploy B directly from Remix without any problem.
When I took off the function in A that creates an instance of B, I can deploy A without any problem.
When I keep this function in A, and took off some random functions from B that doesn't seem to have any relation to the problem, A can be deployed normally.
When I keep this function in A, and comment out some random lines in A, A can be deployed normally.
For example:

function _Redeem(address account, uint amount) internal returns(uint) {
    require(address(_bs[_selectedB[msg.sender]]) != 0x0, "This is not redeemable.");

    amount = _bs[_selectedB[msg.sender]].Redeem(account, amount);
    _totalDeposits += amount;
    _deposits[account] += amount;

    return amount;
}

function _RedeemAll(address account) internal returns(uint) {
    require(address(_bs[_selectedB[msg.sender]]) != 0x0, "This is not redeemable.");

    uint amount = _bs[_selectedB[msg.sender]].RedeemAll(account);
    _totalDeposits += amount;
    _deposits[account] += amount;

    return amount;
}

This contract is not created.

function _Redeem(address account, uint amount) internal returns(uint) {
    //require(address(_bs[_selectedB[msg.sender]]) != 0x0, "This is not redeemable.");

    amount = _bs[_selectedB[msg.sender]].Redeem(account, amount);
    _totalDeposits += amount;
    _deposits[account] += amount;

    return amount;
}

function _RedeemAll(address account) internal returns(uint) {
    require(address(_bs[_selectedB[msg.sender]]) != 0x0, "This is not redeemable.");

    uint amount = _bs[_selectedB[msg.sender]].RedeemAll(account);
    _totalDeposits += amount;
    _deposits[account] += amount;

    return amount;
}

This contract goes ok.

function _Redeem(address account, uint amount) internal returns(uint) {
    require(address(_bs[_selectedB[msg.sender]]) != 0x0, "This is not redeemable.");

    amount = _bs[_selectedB[msg.sender]].Redeem(account, amount);
    _totalDeposits += amount;
    _deposits[account] += amount;

    return amount;
}

function _RedeemAll(address account) internal returns(uint) {
    //require(address(_bs[_selectedB[msg.sender]]) != 0x0, "This is not redeemable.");

    uint amount = _bs[_selectedB[msg.sender]].RedeemAll(account);
    _totalDeposits += amount;
    _deposits[account] += amount;

    return amount;
}

This also goes ok.

Any thoughts on that?


texts: How to convert Hexadecimal values into readable format?

texts:
I'm using etherscan API to fetch the event logs:

http://api-ropsten.etherscan.io/api?module=logs&action=getLogs&fromBlock=3147081&toBlock=latest&address=0x8685ab734df053d736164f5c07e22335ba7dda29&topic0=0xcded53d631ce4a38a1f90d59e5f2f9c023cd28c64aa66488e9462cc4a64a032f&apikey=YourApiKeyToken

The result is a Object with hexadecimal values:

{
  "status": "1",
  "message": "OK",
  "result": [
    {
      "address": "0x8685ab734df053d736164f5c07e22335ba7dda29",
      "topics": [
        "0xcded53d631ce4a38a1f90d59e5f2f9c023cd28c64aa66488e9462cc4a64a032f"
      ],
      "data": "0x0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000b579d4f1546d51980499aa96a2e411be3e449197000000000000000000000000000000000000000000000000016345785d8a00000000000000000000000000000000000000000000000000000000000000000001",
      "blockNumber": "0x30054a",
      "timeStamp": "0x5ae8016c",
      "gasPrice": "0x12a05f200",
      "gasUsed": "0x23aea",
      "logIndex": "0x8",
      "transactionHash": "0xb010aa74f66b00a9827044a3bfe4720bb1e057f243e5cae52307bafe2c2bb5d8",
      "transactionIndex": "0xf"
    }
  ]
}

I'm calling API from my NodeJS server and tried web3.toAscii(), ethjs.toAscii() and ethjs.toUtf8() to convert the hexadecimals values into readable format- none of them working.

Only thing I can convert is hexadecimal numbers into readable numbers like blocknumber using parseInt()

Here's a basic structure of my contract code:

contract EtherBlock {
    uint256 public nonce;
    event eOpenPosition(uint256 indexed PositionKey, address indexed Opener, uint256 EtherTossed, uint8 OddEven);
    function OpenPosition (uint8 OddEven) public {
        emit eOpenPosition(nonce, msg.sender, msg.value, OddEven);
    }
}

Where am I lacking? How can I convert the event data logs into readable format? What is the 'decode' function in Javascript?


texts: Solidity Call Encoded Return Value Difference


texts:
I configured a private testnet according this guide:

https://media.consensys.net/how-to-build-a-private-ethereum-blockchain-fbf3904f337

Now I would like to connect my testnet to MyEtherWallet which is running on my local computer. If I try to connect with the testnet I get the following error message:

Could not connect to the node. Please refresh the page, or see the help page for more troubleshooting suggestions.

What do I have to do in order to connect to my tesnet?


texts: How to detect ETH wallet does not belong to Exchange

texts:
How to detect if ETH address belongs to Exchange?
Is there any proper method or API to detect it 100% correct?


texts: Ropsten: Ether is not in my account, but I think it should be

texts:
I'm a bit confused... I've created an Ethereum account in Ropsten, and have fed it some Ether (more than 20) via faucet.

Yesterday I synched my node with Ropsten and I could see the balance correctly, but unfortunately my local DB got corrupted... so I had to resync.

Today it's almost fully resynched, but although the transactions that put Ether into my account are already in my local copy of the DB, when I ask geth for the balance to my account, it says it's 0.

I just don't understand why is this happening, can anyone help me explain this, please?

This is what I get:

And this shows the transactions that are already uploaded to Ropsten (I haven't spent a single wei of those, as you can see):

Thanks a lot in advance!! :)


texts: How to guarantee an ETH transaction makes it to mainnet

texts:
Is there a library out there that handles the lifecycle of a transaction and ensures it up to a certain guarantee (1-12 confirmations, accepted, etc)?
How do developers handle this issue?  It seems to be from reading some of the articles that there are many scenarios that can throw off a trx.
Thank you : )


texts: Web3js 1.0.x: contract.at not a function

texts:
I am trying to follow this flow to access a  contract that has been mined previously:

var MyContract = new web3.eth.Contract(abiJSON);

// instantiate by address
var contractInstance = MyContract.at(address);

Unfortunatly the contractInstance does not work and I get a contract.at is not a function error. I suspect it has something to do with web3js newest version but I am not sure what to use instead.

I have just tried:

var deployed = new web3.eth.Contract(jsonAbi, address)

But then when I try to call my public function on the contract I get an error:

TypeError: Cannot read property 'call' of undefined

If I look into deployed every thing from the abi to the address is there, so it seems like the fetching of the contract actually worked.


texts: How could Solidity 0.5.0 dynamic sized parameters be declared as storage?

texts:
As I understand it 'memory' in the EVM is a byte array and cannot be dynamically resized, whereas 'storage' is able to be resized. What is happening when a parameter is declared as storage. Where is this storage written to?

Also is my assumption correct that when a 'memory' array is passed in as a parameter, it has a fixed size?


texts: How do I put on gas and setup the blockchain?

texts: I downloaded ethereum wallet nad bought some coins. They dont appear. It says that to view transactions, I have to make a contract. When I try to do that it says its exceeding gas limit. Also it says it's waiting for Blocks. Can't find anywhere on how to set up a the Block. Please help. I'm New.


texts: Options to install Ethereum nodes in a corporate environment

texts:
The main issue to install an Ethereum node in a corporate environment is the possibility to receive connection from unknown nodes. The security department is always concerned in open new doors to attacks since it is a public net.

Is it possible to configure an Ethereum node in a way that it can create connection with external nodes but it cannot accept any connection from unknown nodes?
What are the consequences of this architecture? Would it be possible to send new transactions with this approach?


texts: Smart Contract Transaction Receive on Blockchain Wallet

texts:
I received a transaction coming from a smart contract but Blockchain.info Wallet does not allow to use funds coming from smart contract.

I tried to import my private key on MyEtherWallet but the total amount of Ether is the same as on Blockchain.info Wallet

Who could explain to me how to retrieve the funds from the smart contract transaction?
Transaction on EtherScan:
https://etherscan.io/address/0x01b3f91e8a3d58e2492117b7a0e98f072197d968
On tab "Internal Transactions"

Thank!


texts: What does mean "Failed to retrieve current release"?

texts:
When I start with geth with light syncmode, I get the following error message:

ERROR[date] Failed to retrieve current release          err="can't fetch trie key d0bbe1e9b7e1764fd5f966bd89e4382bb0ece1b2ca83504fb50a3806116edeae: no suitable peers available"

What does it mean?
What should I do?

Note that after that I find peers but admin.peers says they are all in the handshake phase of the protocol.
I am not the only one who has encountered this problem, as shown on reddit.


texts: Cannot get transaction's field "From" using Golang

texts:
How I can get transaction's field "From"?

client, err := ethclient.Dial("https://mainnet.infura.io")
if err != nil {
    log.Fatal(err)
}

blockNumber := big.NewInt(5671744)
block, err := client.BlockByNumber(context.Background(), blockNumber)
if err != nil {
    log.Fatal(err)
}

for _, tx := range block.Transactions() {
    fmt.Println(tx.Hash().Hex())        // 0x5d49fcaa394c97ec8a9c3e7bd9e8388d420fb050a52083ca52ff24b3b65bc9c2
    fmt.Println(tx.Value().String())    // 10000000000000000
    fmt.Println(tx.Gas())               // 105000
    fmt.Println(tx.GasPrice().Uint64()) // 102000000000
    fmt.Println(tx.Nonce())             // 110644
    fmt.Println(tx.Data())              // []
    fmt.Println(tx.To().Hex())          // 0x55fE59D8Ad77035154dDd0AD0388D09Dd4047A8e

    if msg, err := tx.AsMessage(types.HomesteadSigner{}); err != nil {
        fmt.Println(msg.From().Hex()) // 0x0fD081e3Bb178dc45c0cb23202069ddA57064258
    }
}

This code don't show it.

For instance, for transaction https://etherscan.io/tx/0x5d49fcaa394c97ec8a9c3e7bd9e8388d420fb050a52083ca52ff24b3b65bc9c2 it shows nothing.

For transaction https://etherscan.io/tx/0x36368eb4665367100bcb46427e8ac39b7873abfca2015116c478f84642a8812d it shows 0x0000000000000000000000000000000000000000


texts: how to test the TPS in private blockchain

texts: I have set up a private blockchain and I design a new block structure, I want to test the relationship between TPS and block size, are there already some test tools for this use?


texts: Is it possible to unmint an NFT? as in, is the reversal of the tokenisation process feasible?

texts:
Recently an artist friend of mine got scammed on Rarible. The Scammers put up his original artwork for a reserve price after minting 22 copies of which 2 were sold. My friend came to know of this after he noticed that 2 copies had already been sold.
He is currently in the process of drafting a DMCA complaint for taking down the scammer's profile.
Since he wanted to sell the artwork in the future (by himself), he was wondering if it would be possible to UNMINT the existing NFT from the Blockchain, and somehow make it look like it never existed in the first place.
In any case, I'd love to know what can be done when awful shit like this happens.


texts:
I am trying to learn about solidity so I just watch a tutorial about it, I already copy the same code as the tutorial but there is an error with bytes32.
Here it is:

That is the deploy code:

And that is the .sol:


texts: deploying contracts on private node taking forever

texts:
I am trying to deploy contracts on a private geth node. I have mined enough that I have the account balance and the DAG was created.

Here is the netstats for the node :

Now, the contracts start deployment but take too much time. I am stuck for more than 20 minutes on this message :

Writing artifacts to ./build/contracts

Using network 'development'.

Running migration: 1_initial_migration.js
  Deploying Migrations...
  ... 0x68c7b0fcefaf58e20607bfebe8e31bf2d490fa4474478f0ecd96e540c34d58d3

testrpc takes seconds in deployment. Can I make this deployment go fast in any way? I am deploying on the bootstrap node. Even though it shows bootstrap as offline in image, it comes back up in a second.

(Edited according to answer)
truffle :

module.exports = {
  networks: {
    development: {
      host: "172.21.0.6",
      port: 8545,
      // Match any network id
      network_id: "*",
      from: "",
      gas: 4710000
    },
    ropsten: {
      host: "localhost",
      port: 8545,
      network_id: "3",
      from: ""
    }
  }
};


texts: How to call state-changing function in web3.py?

texts:
I have a simple testing contract:

contract TestContract {
    address public owner;
    address public someAddress;

    function TestContract() public {
        owner = msg.sender;
    }

    modifier onlyOwner {
        assert(msg.sender == owner);
        _;
    }

    function setSomeAddress(address _newAddress) onlyOwner public {
        someAddress = _newAddress;
    }
}

According to documentation I should be able to call a state changing function on a contract like this:

transact_params = {
    'from': addr_owner,
    'gas': 21000,
    'gas_price': 1,
}
my_contract_instance.transact(transact_params).setSomeAddress(w3.eth.accounts[1])

However this throws an exception:

File "/usr/local/lib/python3.5/dist-packages/web3/contract.py", line 624, in _find_matching_fn_abi
    raise ValueError("No matching functions found")

I have tried removing parameters, checking ABI (definition is there),... no avail. What am I doing wrong? How can I call a state changing function with web3.py?


texts: Deploying dependent smart contracts using Web3.js?

texts:
On this Truffle web page you see the following code to deploy a smart contract with Web3.js:

http://truffleframework.com/docs/advanced/build_processes

// Step 1: Get a contract into my application
var json = require("./build/contracts/MyContract.json");

// Step 2: Turn that contract into an abstraction I can use
var contract = require("truffle-contract");
var MyContract = contract(json);

// Step 3: Provision the contract with a web3 provider
MyContract.setProvider(new Web3.providers.HttpProvider("http://127.0.0.1:8545"));

// Step 4: Use the contract!
MyContract.deployed().then(function(deployed) {
  return deployed.someFunction();
});

What would this code look like if MyContract.json was dependent on another smart contract?  For example, given a 2_deploy_contracts.js Truffle deployment script file like this:

var ConvertLib = artifacts.require("./ConvertLib.sol");
var MetaCoin = artifacts.require("./MetaCoin.sol");
var Voting = artifacts.require("./Voting.sol");

module.exports = function(deployer) {
  deployer.deploy(ConvertLib);
  deployer.link(ConvertLib, MetaCoin);
  deployer.deploy(MetaCoin);
  // Deploy the voting smart contract.
  deployer.deploy(Voting);
};

My questions are:

I assume I would need to repeat the code involved with Steps 1-3 in the code above for each of my smart contracts? (i.e. - ConvertLib/MetaCoin/Voting).
Are there any other changes that I would need to make so that dependent code is available to the smart contracts that depend on it?  For example, making sure the ConvertLib contract code is available to the MetaCoin contract code?
What is the Javascript equivalent of the deployer.link() statement?


texts: Getting 'Error: VM Exception while executing eth_call: invalid opcode'

texts:
I'm trying to deploy/interact with my first ever Ethereum Smart Contract on testrpc but when I try to 'send a transaction' to my deployed contract I'm getting the following Error..

Error: VM Exception while executing eth_call: invalid opcode

I'm using web3 v0.14.0, solc v0.4.11 to compile, and ethereumjs-testrpc ^4.0.1 as my client.

Here's my solidity code..

pragma solidity ^0.4.11;

contract Voting {
  mapping (bytes32 => uint8) public votesReceived;

  bytes32[] public candidateList;

  function Voting(bytes32[] candidateNames) {
    candidateList = candidateNames;
  }

  function totalVotesFor(bytes32 candidate) returns (uint8) {
    if (validCandidate(candidate) == false) throw;
    return votesReceived[candidate];
  }

  function voteForCandidate(bytes32 candidate) {
    if (validCandidate(candidate) == false) throw;
    votesReceived[candidate] += 1;
  }

  function validCandidate(bytes32 candidate) returns (bool) {
    for(uint i = 0; i < candidateList.length; i++) {
      if (candidateList[i] == candidate) {
        return true;
      }
    }
    return false;
  }
}

and here's my JavaScript file..

const fs = require('fs');
const solc = require('solc')
const Web3 = require('web3');
const web3 = new Web3();

web3.setProvider(new web3.providers.HttpProvider('http://localhost:8545'));

const address = web3.eth.accounts[0];

const code = fs.readFileSync('Voting.sol').toString()
const compiledCode = solc.compile(code)

const abiDefinition = JSON.parse(compiledCode.contracts[':Voting'].interface)
const byteCode = compiledCode.contracts[':Voting'].bytecode

const VotingContract = web3.eth.contract(abiDefinition)
const deployedContract = VotingContract.new(['Rama','Nick','Jose'], {
  data: byteCode,
  from: web3.eth.accounts[0], gas: 4712388
});

const contractInstance = VotingContract.at(deployedContract.address)

contractInstance.totalVotesFor.call('Rama') // Error: Error: VM Exception while executing eth_call: invalid opcode

Any ideas on what I'm doing wrong? Also, please let me know if my language is correct..

If you need any more information my repo is here: https://github.com/iMuzz/hello-world-ethereum-contract


texts:
After i created a wallet for a user i want to modify his balance, how could i do that without setting the account  address' balance in the genesis, I'm using quorum blockchain with web3j.

Thank you!


texts:
What is the size of the Ethereum blockchain for full and light nodes?

What is the size of the Ethereum blockchain, and where can I look it up?

Furthermore, does the size depend on the particular client, e.g., geth?

How much does the size increase over time? Is the growth rate fixed?


texts: What is the ROI of owning Ether after entering POS?

texts: It's from my understanding you make ETH by owning ETH during POS. And assuming that is true how will ROI be determined?


texts:
I'm storing IPFS hash in solidity using this guide

https://www.reddit.com/r/ethdev/comments/6lbmhy/a_practical_guide_to_cheap_ipfs_hash_storage_in/

    const cid = "QmNXnCWPS2szLaQGVA6TFtiUAJB2YnFTJJFTXPGuc4wocQ";

    const fromIPFSHash = hash => {
        const bytes = bs58.decode(hash);
        const multiHashId = 2;
        // remove the multihash hash id
        return bytes.slice(multiHashId, bytes.length);
    };
    const toIPFSHash = str => {
        // remove leading 0x
        const remove0x = str.slice(2, str.length);
        // add back the multihash id
        const bytes = Buffer.from(`1220${remove0x}`, "hex");
        const hash = bs58.encode(bytes);
        return hash;
    };

    it('Store encoded ', async () => {
       const bytes32 = fromIPFSHash(cid);
          const str = bytes32.toString('hex')
          console.log(str);

          await instance.setBytes.sendTransaction(str);
          const returnedBytes = await instance.getBytes.call();

          console.log(returnedBytes);
          const originalCid = toIPFSHash(returnedBytes);
          console.log(originalCid);//QmUu4JqHgHcT6Q8PxvDn1UzZq2utkgf7RfgGv4eeYZ3Lyu

          assert(originalCid == cid); // it fails
});

The above assert fails .

pragma solidity ^0.4.4;

contract Hello {
    bytes32 x;
    function getBytes() returns(bytes32){
        return x;
    }
    function setBytes(bytes32 b)  {
        x = b;
    }

}


texts:
In a contract you can define a dictionary to store data. For example

mapping (address => string) public cadenas;

function send (string cadena) public {
    cadenas[msg.sender] = cadena;
}

If I send 1000 transactions to this contract, I will be storing 1000 text strings. Are there any limits or penalties for the size of the data recorded by a contract?


texts:
I can see events in a private net, but when I connect to "real" net, I can not see them. Meaning .watch(function(err, result) is never called.
My theory is I am using lightning, and it probably means events are not loaded.

Am I correct?
What else can it be?


texts:
I'm a student trying to install a truffle test RPC client (just for simple contract deployment in small scale).

I am using a remote Ubuntu machine in my university, and i don't root privileges.
Although npm is installed in the environment, i can't use it without sudo.

I already installed go-ethereum and geth using "git clone" and manual building (makefile building). I did not manage to do the same with the truffles repo.

Does any one know how to install truffle manually without npm?

Thanks


texts: MetaMask ethereum.enable() not responding after logout. How to reactivate?

texts: So I found out that after logging out of MetaMask. ethereum.enable() stop working and is not triggering the login prompt window. The only way to reactivate it, is by closing chrome, and start it once again. This is not so elegant. Is there a javascript for that?


texts: How to decrypt private key form keystore file, without using third party applications?

texts: I would like to write a piece of code that takes input as UTC key store file and password, and returns decrypted Private Key. I am aware of options like "MyEtherWallet" but I would like to do using my code. Any help/resources that I can use is appreciated.


texts: Geth python node no transactions / no data

texts:
I want to get transaction information on the blockchain ethereum using Go Ethereum (GETH) with web3 and python.
I am running eth node on windows using the following command :
geth --http --syncmode full

And here is my python code (very simplified)
from web3 import Web3
web3 = Web3(Web3.HTTPProvider("http://127.0.0.1:8545"))
tx = web3.eth.get_transaction('0xbbc4f1e4253cbb72933b76b4ef1d68aa32f53b56e061df18925c7d3c51e56064')
tx_count = web3.eth.get_transaction_count('0x03C939a9aDdff931411aC331C34eEb27c12D919E')

My issue is that tx is None and tx_count is 0, but as you can see on Etherscan, transaction exists and wallet contains transactions.
I have tried to create a wallet and it works but it seems like I cannot get transactions on the blockchain.


texts:
I've been trying to teach myself how to program smart contracts in Vyper and I was trying out a toy problem where the contract transfers USDC to itself and then mints some Compound USDC on Compound Finance.

I've been attempting to execute a function compound using MEW and it fails (out of gas or repeatedly failing error) before it even asks me to sign the transaction. I'm a little bit lost as to why it is failing and I can't seem to find a good tool to debug it. I've approved the contract with USDC AND cUSDC.

Here is my code:

from vyper.interfaces import ERC20

contract Compound():
    def redeem(quantity: uint256) -> uint256: modifying
    def mint(quantity: uint256) -> uint256: modifying
    def approve(target: address, quantity: uint256) -> bool: modifying
    def balanceOf(target: address) -> uint256: constant
    def transfer(to: address, tokens: uint256) -> bool: modifying

owner: address
cusdc_token: Compound
usdc_token: ERC20

@public
def __init__():
    self.owner = msg.sender
    self.cusdc_token = Compound(0x39AA39c021dfbaE8faC545936693aC917d5E7563)
    self.usdc_token = ERC20(0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48)

    self.usdc_token.approve(self.cusdc_token, 99998075535048195174647562)

@public
def kill():
    if msg.sender == self.owner:
        selfdestruct(self.owner)

@public
def compound(quantity: uint256, trans_cost: uint256):
    assert self.usdc_token.transferFrom(msg.sender, self, quantity)
    assert self.cusdc_token.mint(quantity) == 0

You'll notice that there is no code to return USDC or cUSDC to my account. That's just because I've been progressively deleting code to try and work out where its failing.

What am I missing? Any help would be much appreciated! I'm sure it's fairly straight forward!


texts:
I am currently looking for the costs to execute a simple "Hello World" contract, where would I be able to find or estimate that?

I have tried some googling but to no avail.

Br
NN


texts:
Getting errors about gas limits on a already successfully deployed contract and now transactions on Pancake swap aren’t going through with error “Pancake: K” or this message
“we are trying to fix a bug on the chain
[00:21]
this
code: -32603
data:
code: -32000
message: "gas required exceeds allowance (41335035) or always failing transaction"
proto: Object
message: "Internal JSON-RPC error."
proto: Object
and from user side“
This is the source code
https://github.com/papelprotocol/Papel.sol/blob/main/Papel.sol
We need help ASAP there’s a lot of holders contract has already been audited what am I missing?!


texts: How can I split certain part of a number variable?

texts:
In a smart contract using Solidity, how can I split certain characters of a number variable?

I specifically need to take last two symbols of a hexadecimal number.


texts: I want to create a new cryptocurrency from BNB. My question is, how can I create the first genesis block?


texts: How to implement Ethereum protocol to some tinyOS, e.g, contiki?

texts:
I find out Ethereum has many implements to many OS with many different languages.

But i don't know if I want to use ethereum as protocol on contiki OS or cooja simulation, so what is the best choice for my case? (with C language).
And How can install Ethereum on Contiki as protocol? And i can call it as an API.
Here, Contiki is a kind of tinyOS(http://www.contiki-os.org/).

Please help me fix this issue.

Thank a lot.


texts: How can Ethereum be used to help a Peer to peer car rental company

texts:
I'm a university student and I had an idea for a Peer to peer car rental service. I have been doing some research into blockchain and I found Ethereum. My knowledge is extremely limited (keep in mind I'm 21), I read that ethereum is perfect for this application but I have no idea how and what it would require? Also, how can a business make money by using Ethereum for a peer to peer business?

I'd love some general information about Ethereum and its uses but also specifically how it would make this business more effective than traditional methods.

Thank you very much.

Ps please keep the responses as simple as possible as aforementioned my knowledge is extremely limited.


texts:
1) Ethereum needs to store lots of data whose identifier can be said to be purely random. It makes use of LevelDB, whose indexing/sorting properties are useless here since the very key is random.

The obvious questions are - why LevelDB? Why not MySQL for instance, so to drastically improve information retrieval performance. (introduce indexing based on block height etc) Let's forget the security/ concurrency aspects which I've seen brought up. The purpose of a database is to facilitate efficient data storage and retrieval. Proper software design should be able to secure access to a local MySQL instance as well.

Thus, what's the rationale?

2) How is the data laid out in the database?


texts: adaptive vs. non-adaptive adversaries? Is there a precise, unique and general definition? (Updated)

texts:
In this Ethereum github page (Link to the page: https://github.com/ethereum/wiki/wiki/Sharding-FAQ#what-are-the-security-models-that-we-are-operating-under) there is a very brief definition of the adaptive vs. non-adaptive adversaries as follows:

  an adversary is adaptive if they can quickly choose which portion of the validator set to "corrupt", and non-adaptive if they can only make that choice far ahead of time.

But this definition is not clear to me. And it also only consider Ethereum platform.

For example, What does it mean that an adversary choose quickly a portion of validator set to corrupt them ? How to say their choice was quickly or not ?

From my point of view, the definition is not clear and precise enough by which we could recognize if an adversary is adaptive or non-adaptive.

P.S. I found a definition in this paper (Link to the paper: https://arxiv.org/ftp/arxiv/papers/1206/1206.6400.pdf) as follow. But I am not sure if this definition is the same that in the above github page has been mentioned.

  All adversary types are strategic and possibly malicious, have
  unlimited computational power, and are free to use random bits when
  choosing their loss functions. If the adversary is not restricted
  beyond the setting described above, he is called an adaptive
  adversary. Other adversary types are restricted in various ways.

Important note: Regarding to the paper that I added to my question (in P.S: arxiv.org/ftp/arxiv/papers/1206/1206.6400.pdf),  can we say that  adaptive adversary is a general term in security?

And if yes, what is the best and most precise and general definition?

Important Update (1): To the best of my knowledge, the term "adaptive adversary" is used in many scientific papers in computer security, but I could not find any clear and precise definition for this term yet.

As another example, I bring another quote here from another paper as follows: (there are many other similar examples.)

  We note that some previous works like Algorand and Ouroboros consider
  a stronger fully-adaptive adversary that can freely choose
  controlled participants for each time window. Our take is that such a
  fully-adaptive adversary is interesting, and worth studying, but often
  not realistic. In practice, platform compromise is hard to detect and
  repair. Furthermore, a compromise of one computing platform does not
  mean that another is no longer in control of the adversary. For these
  reasons, we focus on non-adaptive adversaries in this work.

Link: https://arxiv.org/pdf/1804.07391.pdf

Important Update (2): I brought up this question in security.stackexchange and I received this answer: "An adaptive adversary can adapt to the environment and responses from the environment as part of the attack. A non-adaptive adversary cannot." (https://security.stackexchange.com/a/213278/187204) that could mean this term is a general term in security. I also found this term in many papers on computer security, and it is used in even non-blockchain-based fields. As a result, "adaptive adversary" seems to be a general term and is not used only for validator set.


texts: Why USDC interest rates are so high compared to USD interest rates?

texts:
USDC is a stable coin, pegged to USD, so there should be no risk (or very little) from owning some. However, the lending rate for USDC is between 3% and 13%: https://defirate.com/usdc/
Since higher return comes from higher risk, I wonder where is the risk for lending USDC? I cannot see much more than USD lending. Maybe hacking risk? Something else?


texts: Account management risks of booting into Tails OS from USB using a "partially air-gapped" Linux PC

texts:
My threat tolerance is around a 3 out of 5 on the paranoia scale. What are the practical account management risks of using a flash drive loaded with Tails OS to boot into a Linux PC, which will only be offline when using Tails for account management?

My understanding is that if I boot into Tails via flash drive, after a system shutdown, the Tails OS environment will be sandboxed from the underlying host OS environment. So, if there's software process isolation and partial network isolation would it really matter if the system is intermittently online? Are there any plausible and significant risks to recommend against this approach?

For context, I've been reading this GitBook on Ethereum account management "best practices". Unfortunately, it doesn't go into much depth on this specific variation in the recommended wallet set-ups. Note: I'd prefer not having to buy any additional hardware for this particular use case.


texts: How do I keep geth running? --daemon doesn't work

texts:
So I run

geth --testnet --rpc --rpcport 8545 --rpcaddr 0.0.0.0 --rpccorsdomain "*" --rpcapi "eth,web3" console

But when I exit out of putty geth stops.

I tried to add:

--daemon

But it didn't work.

How do I keep geth running?


texts:
I have the following array in my smart contract:

string[] public saved_texts;

function getSavedTextsCount() public constant returns(uint) {
    return saved_texts.length;
}

I created getSavedTextsCount to basically get the length of my array.

My web3 function looks like the following:

  basicInfoUpdate: function () {
    TextContract.deployed().then(function (instance) {
      let element = ''
      for (let index = 0; index < instance.getSavedTextsCount; index++) {
        element += instance.saved_texts.call(index)
        element += '</br>'
      }

      document.getElementById('transactions').innerHTML = element
    })
  },

However, I  do not get any result back. Any suggestions what I am doing wrong?

I appreciate your replies!


texts: Where to place static-nodes.json for geth

texts:
I am setting up a private Ethereum network using puppeth whic creates the sealer nodes on various servers.

To aid peer discovery, it has been suggested that we include a list of enodes in the file static-nodes.json for geth to use.

Where do we place static-nodes.json?

The datadir directory containing folders geth and keystore, and the filegeth.ipc`
The datadir/geth directory containing folders chaindata, lightchaindata, nodes, and the files LOCK, nodekey, transactions.rlp?

Additionally, where do we place trusted-nodes.json? Can we let geth use both files trusted-nodes.json and static-nodes.json, or must we choose one of the two to use?

Does the nodes added using admin.addPeer gets stored somewhere, or must we re-add these nodes again if we restart geth?


texts: Getting a solc error: uint176 - Identifier not found or not unique

texts:
I'm working on an "Infosphere" contract, an arbitrary key/value store any individual or contract can use.

You can take a look at it here: https://github.com/SafeMarket/dapp/blob/3893cdb499cafae3581bf0ff814c1a80b6640297/app/contracts/Infosphere.sol#L963-L974

I'm getting an error when I try to compile with node solc.


texts: How to create new contracts (contract2a, b, c, etc) from a function in contract1 and then access the new contracts

texts:
This is my first question here and I’ll try to keep it specific.

I have a “Baker” contract that has a function that makes a new “Cookie” contract. I deploy it in Remix and have problems interacting with the new Cookie contracts that are made.

Expected behavior:

Use bakeNewCookie function to create a new contract and pass it’s state variable “CookieName” a string so that I can identify it later.
When i “bakeNewCookie” the new Cookie contract has a constructor that defines it’s state variable “CookieAddress” with address(this) (I want to access each Cookie contract via the contract address).
Then I want to use the “myCookieAddress” function which takes the address from one of the new Cookie contracts and gives me the “CookieName” variable of said Cookie contract.

Actual behavior:

After calling “bakeNewCookie” I don’t see the new contract I created.

Question:

Do I actually create new Cookie contracts on the blockchain with this code? In the future I want users on a website to access the Cookies they have created and display them on a website.
Right now I’m trying to use the new contract address as the identifier to interact with them. Is there a better way to do it? I need a unique ID for each cookie that is tied to its information. Ideally I’d like to create a mapping of the new contracts but that doesn’t seem to be possible.
Why doesn’t the “myCookieAddress” function work as expected?

Thanks so much in advance for the help!

pragma solidity ^0.5.1;

contract Cookie {
    address public CookieAddress;
    string public CookieName;

    constructor() public {
        CookieAddress = address(this);
    }

    function theCookieInfo() view public returns(address, string memory) {
        return (CookieAddress, CookieName);
    }

}

contract Baker is Cookie {

    address public BakerAddress;
    address[] public CookieAddresses;

    constructor() public {
        BakerAddress = address(this);
    }

    function bakeNewCookie(string memory _name) public returns(bool) {
        new Cookie();
        Cookie.CookieName = _name;
        CookieAddresses.push(CookieAddress);
        return true;
    }

    function getCookieArray() view public returns(address[] memory) {
        return CookieAddresses;
    }

    function myCookieAddress(address _addressOfCookie) view public returns(string memory) {
        Cookie my_cookie = Cookie(_addressOfCookie);
        return my_cookie.CookieName();
  }

}


texts:
I am writing a Dapp. I'm not an expert. It works perfectly on Edge, Firefox, and Chrome (with MetaMask). But I get the following error on Opera when the cryptowallet is on but not synced:

{
  "error":{
    "code": -32503,
    "message": "wallet address undefined"
  },
  "id": 1,
  "jsonrpc": "2.0"
}

If I refresh the page, the error dissapears.

My web3.js component is as follows:

<pre>
import Web3 from 'web3';

let web3;

if (typeof window !== 'undefined' && window.web3 !== undefined) {

  const getProvider = async () => {
  await window.web3.currentProvider.enable();
  };
  getProvider();

  web3 = new Web3(window.web3.currentProvider);
  window.ethereum.autoRefreshOnNetworkChange = false;
} else {
  const provider = new Web3.providers.HttpProvider(
    '//rinkeby.infura.io/v3/key'
  );
  web3 = new Web3(provider);
}
</pre>

I am using:

    "next-routes": "^1.4.2",
    "react": "^16.11.0",
    "react-dom": "^16.11.0",
    "semantic-ui-css": "^2.4.1",
    "semantic-ui-react": "^0.88.1",
    "solc": "^0.5.11",
    "tinify": "^1.6.0-beta.2",
    "truffle-hdwallet-provider": "^1.0.17",
    "web3": "^1.2.4"

Any help would be greatly appreciated.


texts: Checking whether a value is a valid enum value

texts:
With the following enum definition in Solidity code...

enum Direction { North, South, East, West }

... I would like to set up a for-loop that iterates over this enum's values, e.g.

for (uint8 dirn = 0; dirn < xxx; dirn++) { ... }

Is there a way for the code to check what the size of the enum is, i.e. what should replace xxx, other than the hard-coded literal value 4?


texts: Need to iterate a uint 4 times? No problem. 5 times? Nope! Called function suddenly needs to be payable.....?

texts:
I have a public uint variable denoting 'which round' it is and a function that advances rounds and does processing alongside the round advancement:
       uint public round;

       function completeRound() public inPaused() inRound() {
            if (round == 6) {
              // win
          } else {
            reduceByHalf();
            round.add(1);
          }

       }

If i run this in remix, it runs 4 times and then consistently fails on the 5th, indicating that a function suddenly needs to be payable:
transact to Playingwithsmartcontracts.completeRound errored: VM error: revert. revert The transaction has been reverted to the initial state. Note: The called function should be payable if you send value and the value you send should be less than your current balance. Debug the transaction to get more information.
If I comment out round.add(1) right under where reduceByHalf is called, the code works all day long. I can click it indefinitely with no errors in Remix.
Strangely, this started as an Enum to track the rounds and that had the same exact problem. While advancing the enum, i could do it 5 times before the above failure and commenting it out made everything work.
reduceByHalf code doesnt seem to be the offender, but it is shown below in case it has a bearing on the problem:

    struct Foo {
        address owner;
        uint mintedRound;
        uint winningRound;
    }
    struct FooOwner {
        uint[] foos;
        uint totalWinningFoos;
    }

    uint[][5] roundFoos;
    uint[][5] roundWinners;

    mapping(uint => Foo) public winningFoos;
    mapping(address => FooOwner) public fooOwners;

    uint totalWinningFoos;

    function shuffleFoos (uint256[] memory _array) internal view returns(uint[] memory){
        uint[] memory clone = cloneArray(_array, _array.length);

        for (uint256 i = 0; i < clone.length; i++) {
            uint256 n = i + uint256(keccak256(abi.encodePacked(msg.sender, block.timestamp))) % (clone.length - i);
            uint256 temp = clone[n];
            clone[n] = clone[i];
            clone[i] = temp;
        }

        return clone;
    }

    function cloneArray(uint256[] memory _array, uint256 _length) internal pure returns (uint256[] memory) {
        uint256[] memory array = new uint256[](_length);
        for (uint256 i = 0; i < _length; i++) {
            array[i] = _array[i];
        }
        return array;
    }

    function reduceByHalf() internal  {
        uint[] memory clone = shuffleFoos(roundFoos[round]);

        uint halfLength = 0;

        halfLength = roundFoos[round].length.div(2);
        for (uint w = 0; w < halfLength; w++) {

           uint fooId = clone[w];

           roundWinners[round].push(fooId);
           winningFoos[round].winningRound = round;

           address fooOwner = winningFoos[fooId].owner;

           fooOwners[fooOwner].totalWinningFoos = fooOwners[fooOwner].totalWinningFoos.add(1);
        }

        totalWinningFoos = totalWinningFoos.add(halfLength);
    }

As far as I know, I am not sending value, and not sure why it only thinks im sending value on transaction execution 5.
Would anyone be able to help me understand what Remix/Solidity is mad about?


texts: Torrents also increase in speed as the number of peers increases. swarm Is the same? This is because dividing the data into chunks is the same.


texts: How to add a file to IPFS using the API?

texts:
I have tried some APIs of IPFS like cat, ls. But I am not able to add the file using API. As there is no proper documentation of IPFS API calls.

How can I add a file on IPFS using API?


texts: Does the ETC whitehat withdraw contract still work?

texts:
Apparently the withdraw period has ended.  https://blog.bity.com/2017/04/03/the-whitehat-withdrawal-contract-distribution-period-is-now-reaching-its-end/

Can someone confirm this?


texts: SubscribeFilterLogs - cannot unmarshal array into Go value of type types.Log

texts:
i have a problem to get the Logs. Here is the Code:

query := ethereum.FilterQuery{
    Addresses: []common.Address{contractAddress},
}

ctx := context.Background()
    ethereumLogsCh := make(chan types.Log)
sub, err := ethClient.SubscribeFilterLogs(ctx, query, ethereumLogsCh)
if err != nil {
    log.Println("Subscribe:", err)
    return err
}

for {
    select {
    case err := <-sub.Err():
        log.Fatal(err)
    case ethLog := <-ethereumLogsCh:
        log.Println("Log:", ethLog)
    }
}

System information:
Geth version: 1.8.0-unstable
OS: Linux

Expected behaviour:
I would expect to get a types.Log object when an event is triggered from the contract.

Actual behaviour:
Im getting an Erro: cannot unmarshal array into Go value of type types.Log.
What i'am doing wrong? Does the blockchain (in my case a local parity BC) send more than one log object?

Thx for the help.


texts: Which Ethereum accounts have the most Ether?

texts: Where can someone get a list of all the ethereum accounts and sort it by the # of ether they have?


texts: Solidity v0.5: Data location in return values of function

texts:
I am aware that we need to specify data location for returned values in function as of Solidity v0.5. Is this the case for all variable types (I have come across sources that mention it is only for struct, arrays, and mapping)?

I am trying to run the following code but for some reason it only requires the string variable to have a data location specified, and not the uint or bool values:

// Get user information using an address
function getUser(address _address) public view returns(string memory, uint, bool) {
    User memory getM = addressToUser[_address];
    return(getM.username,getM.contributionBalance,getM.verified);
}

This code gives no compilation errors but adding memory to uint and bool does.
I wondered why this is the case.


texts: How to hide/protect smart contract arguments

texts:
In Ethernaut level 8 you are given this contract to hack:

pragma solidity ^0.4.18;

contract Vault {
  bool public locked;
  bytes32 private password;

  function Vault(bytes32 _password) public {
    locked = true;
    password = _password;
  }

  function unlock(bytes32 _password) public {
    if (password == _password) {
      locked = false;
    }
  }
}

The password which is passed into the contract through the constructor arguments is easily found; By going to the creation transaction in Etherscan and reading the init input code in text. Or by:

web3.eth.getStorageAt(contractAddress, 1,  function(error, result) {password = result}))

  Is there a way to encode these arguments (bytes32 _password)  and make it so no one can
  retrieve them via etherscan or web3?


texts: Truffle Ropsten Running migration: 2_deploy_contracts.js fails with: TypeError: Cannot convert undefined or null to object

texts:
Error encountered, bailing. Network state unknown. Review successful
  transaction s manually.

So I'd checked  TxHash transactions manually, is here:
https://ropsten.etherscan.io/tx/0x3b5415de9584f43aa6155843a64e453a49189e16fc83cf00e2323935c045f460

truffle(development)> migrate --network ropsten
Using network 'ropsten'.

Running migration: 2_deploy_contracts.js
  Deploying SafeMath...
  ... 0x9eb2ce16e8ed3e0dbb4a7e286a148f5c8dbca7233cfa49a61a02cc6df6214725
  SafeMath: 0x29373c7174c28927a127a156f4f4e1ea4ba89e0c
  Deploying Ownable...
  ... 0x20ea24cf646cb77e11ea35861f073486e2a392ffbe04b0f86766b48bb696dd89
  Ownable: 0x656f2084ff1916a887e138248452ae93b15fb74d
  Deploying Pausable...
  ... 0x0ada99f10d0e25ad37929cf7f2ab03f41d10a84e47dbc4dec83a1db40b5e2560
  Pausable: 0xed152244733a6d06679d9c5f9e6ba9afd970ff22
  Deploying BasicToken...
  ... 0x8b253db846b5c4411ac9dbb0c85654416a4e0010f016317b8faff4322d227bb6
  BasicToken: 0xcd4460ca0f93f078cafbbc4b7ddfa9d95f4c3530
  Deploying StandardToken...
  ... 0x3b5415de9584f43aa6155843a64e453a49189e16fc83cf00e2323935c045f460
  StandardToken: 0x678fd6ebdbb9dbbb961384c89bcc856c726a04ba
Error encountered, bailing. Network state unknown. Review successful transaction
s manually.
TypeError: Cannot convert undefined or null to object
    at C:\Users\ROBERT\AppData\Roaming\npm\node_modules\truffle\build\webpack:\.
-deployer\src\actions\deploy.js:16:1
    at <anonymous>
    at process._tickDomainCallback (internal/process/next_tick.js:228:7)

  Standardtoken has been deployed successfully despite the error but the
  process has been stopped and not complete deploy PatadiseToken.sol and
  ParadiseTokenSale.sol.

1_initial_migration.js ,
Works fine!

var Migrations = artifacts.require("./Migrations.sol");

module.exports = function(deployer) {
  deployer.deploy(Migrations);
};

2_deploy_contracts.js

module.exports = function(deployer, network, accounts) {
    // Use the accounts within your migrations.
    //console.log("Accounts: " + accounts);

    var userAddress = accounts[1];

    deployer.deploy(SafeMath);
    deployer.deploy(Ownable);
    deployer.link(Ownable, Pausable);
    deployer.deploy(Pausable);

    deployer.deploy(BasicToken);
    deployer.link(BasicToken, SafeMath);
    deployer.link(BasicToken, ERC20Basic);

    deployer.deploy(StandardToken);
    deployer.link(StandardToken, BasicToken);
    deployer.link(StandardToken, ERC20);

    deployer.deploy(ParadiseToken, userAddress);
    deployer.link(ParadiseToken, StandardToken);
    deployer.link(ParadiseToken, Ownable);
    deployer.link(ParadiseToken, SafeMath);

    var time = new Date().getTime() / 1000;

    var monkey = 1234;

    deployer.deploy(ParadiseToken, accounts[1]).then(function() {
        return deployer.deploy(ParadiseTokenSale, accounts[1], 10, 20, 1, time, 2, 15000, ParadiseToken.address);
    });

};

I think the problem is in 2_deploy_contracts.js

truffle.js is here:

var HDWalletProvider = require("truffle-hdwallet-provider");
var infura_apikey = "<My key is here> ";
var mnemonic = "<My MetaMask Seed Phrases is Here>";

module.exports = {
  networks: {
    development: {
    provider: new HDWalletProvider(mnemonic, "http://127.0.0.1:8545/"),
      network_id: "*" // Match any network id
    },
    ropsten:  {
      provider: new HDWalletProvider(mnemonic, "https://ropsten.infura.io/" + infura_apikey),
      network_id: 3,
    }
  },
};

testrpc output:

EthereumJS TestRPC v6.0.3 (ganache-core: 2.0.2)

HD Wallet
==================
Mnemonic:      venue denial battle taxi park army into reform spice situate frie
nd mango
Base HD Path:  m/44'/60'/0'/0/{account_index}

Listening on localhost:8545

I'm using mnemonic MetaMask Seed Phrases

Truffle compile works fine !

  ParadiseToken.sol and ParadiseTokenSale.sol is here:

https://ropsten.etherscan.io/address/0xbe1121b96da695cbe68cf8e41f2fba6ea9eb80e9#code

Could someone point out why is like that. Is here an obvious error. Did I miss something?
Thank You, Robert.


texts: Web3 event listener - timing issue when immediately retrieving contract values

texts:
I'd like to be able to immediately get a struct value from a mapping after calling a function that updates the struct, however, when testing with Ganache, sometimes the event arrives to the listener before the struct has been updated in the contract.  I've noticed that the issue is especially bad when trying to transfer value within the function that emits the event.

Here's a small demo contract to illustrate the issue.

pragma solidity ^0.5.8;

contract Names {

    uint lastId;
    mapping(uint => Name) public numberedNames;

    struct Name {
        string name;
    }

    constructor() public {
        lastId = 0;
    }

    event LogNewName(uint id, string name);
    event LogNameUpdate(uint id, string name);

    function setName(string memory name) public {
        numberedNames[lastId] = Name(name);
        emit LogNewName(lastId, name);
        lastId++;
    }

    function changeName(uint id, string memory name, uint transferRequest) public payable {
        Name storage existingName = numberedNames[id];
        existingName.name = name;
        msg.sender.transfer(transferRequest);
        emit LogNameUpdate(id, name);
    }

}

And here's what I'm trying do in node within the event listener.

async function listenerCallback(data) {
    await utils.pause(1000); // pause 1 second - adding this will prevent mappingStruct from being stale, but not an ideal solution
    const mappingStruct = await contract.methods.numberedNames(data.returnValues.id);
    console.log(mappingStruct)

    // update db based on event information
}

Again, if I have a transfer in the function (see the changeName function above), the value of mappingStruct will always be stale unless adding a delay.  However, even if not transferring value, it is sometimes still stale.

Adding the delay complicates things in my case so it would be highly preferable to address this in the contract code if at all possible.

Any suggestions?  Also, since this is my first Ethereum project, will this be an issue on the mainnet?


texts: 1 ETH stuck in a live contract, 0.1 ETH reward if you can get it back

texts:
Yep, my fault for playing around with contracts on the live net so I'm only to blame but wondered if anyone with more knowledge can help or just confirm that my 1 ETH is now forever stuck or there is a way I can get it.

I know what what the problem is, it's that I've used the safeWithdrawal once already so the var 'amountRaised' has not been reset and if I send more it doesn't match.

What happened was I sent 0.5 ETH, then used safeWithdrawl and got it back fine. Later I sent 1 ETH and tried to safeWithdrawl that. Because amountRaised didn't clear it tries to withdraw 1.5 ETH when there is only 1ETH and would do the same if more was sent to it. Any help or am I stuck?

pragma solidity ^0.4.2;
contract token { function transfer(address receiver, uint amount); }

contract Crowdsale {
    address public beneficiary;
    uint public fundingGoal; uint public amountRaised; uint public
    deadline; uint public price;
    token public tokenReward;
    mapping(address => uint256) public balanceOf;
    bool fundingGoalReached = false;
    event GoalReached(address beneficiary, uint amountRaised);
    event FundTransfer(address backer, uint amount, bool
    isContribution);
    bool crowdsaleClosed = false;

/* data structure to hold information about campaign contributors */

/*  at initialization, setup the owner */
function Crowdsale(
    address ifSuccessfulSendTo,
    uint fundingGoalInEthers,
    uint durationInMinutes,
    token addressOfTokenUsedAsReward
) {
    beneficiary = ifSuccessfulSendTo;
    fundingGoal = fundingGoalInEthers * 1 ether;
    deadline = now + durationInMinutes * 1 minutes;
    price = 25;
    tokenReward = token(addressOfTokenUsedAsReward);
}

/* The function without name is the default function that is called whenever anyone sends funds to a contract */
function () payable {
    if (crowdsaleClosed) throw;
    uint amount = msg.value;
    balanceOf[msg.sender] = amount;
    amountRaised += amount;
    tokenReward.transfer(msg.sender, amount * price);
    FundTransfer(msg.sender, amount, true);
}

modifier afterDeadline() { if (now >= deadline) _; }

/* checks if the goal or time limit has been reached and ends the campaign */
function checkGoalReached() afterDeadline {
    fundingGoalReached = true;
    GoalReached(beneficiary, amountRaised);
}

function closeCrowdSale()  {
  if (beneficiary == msg.sender) {
  crowdsaleClosed = true;
  }
}

function safeWithdrawal() {
  if (beneficiary == msg.sender) {
      if (beneficiary.send(amountRaised)) {
          FundTransfer(beneficiary, amountRaised, false);
      }
  }
}
}


texts: Can you mine Bitcoin on the Ethereum Virtual Machine?

texts: Code can be written on a smart contract to be deployed to the network, where nodes do the computational work for a fee and a given gas work. I was wondering if it would be theorectically possible, to load a bitcoin mining script on to a smart contract? What would be a reason why this couldn't work (aside from fees)? Can you mine on-chain for a different blockchain?


texts: i stupidily wrapped my ether to weth from metamask using uniswap,

texts:
I stupidly wrapped my ether to WETH from MetaMask using Uniswap. I then used https://relay.radar.tech/ to unwrap it but its taking so long. Here is the transaction hash
0x369d1412b0466fddcbabf431222c41654dd8a01c2bcb0dd43a897aec93a30464.
If anyone could help I would appreciate it very much.


texts: transfer of ERC721 between EOA to contract

texts:
If I have contract A and contract B (which follows erc721 standards), both have implemented the OnERC721Received function, how does the transfer of any tokenId take place atomically?
If I have a token with tokenId X (uint256) in contract A and owned by Y( address) and the contract B also has a minted token with the same tokenId X, will transferring that token from A to B takes place, if yes doesn't the tokenId collide? how does it work under the hood, does it change the owner to contract B or mint a new token in contract B and burn from A?
Any help would be really appreciated!


texts: React: Please pass numbers as strings or BigNumber objects to avoid precision errors

texts:
Here is my onSubmit function:

onSubmitModifyAllocation = async event => {
  event.preventDefault();

  const accounts = await web3.eth.getAccounts();

  await fund.methods.modifyAllocation(this.state.address, this.state.allocation).send({
    from: accounts[0],
    allocation: web3.utils.toWei(this.state.value, 'ether') // Here is an issue
  });

And the form:

<form onSubmit={this.onSubmitModifyAllocation}>

Modifies the max investment limit allowed for an investor

    Address
    <input
      value={this.state.address}
      onChange={event => this.setState({ address: event.target.value })}
    />

    Allocation, denominated in ether
    <input
      value={this.state.allocation}
      onChange={event => this.setState({ allocation: event.target.value })}
    />

  <button>Change allocation</button>
</form>

I've tried to convert the allocation value to BN, but no luck. What's the best approach to managing the error?


texts:
I am getting this error on contract deployment

  "undefined errored: Cannot read property 'op' of undefined "

when using remix and have no clue why, when I remove the helloAddress and remove the param it does not show

pragma solidity 0.4.17;

contract HelloWorld{

    address public owner;
    address public helloAddress;

    function HelloWorld (address _helloAddress) public {
        owner = msg.sender;
        helloAddress = _helloAddress;
    }

}


texts: Running ropsten testnet with docker error

texts:
I would like to try to run ethereum client at my server configured with docker geth image. But when I set the genesis block according to the command below I got an error about the reference for the genesis block file:

sudo docker run -it -v /mnt/ethereum_data/ropsten:/root/.ethereum ethereum/client-go:alpine init /mnt/ethereum_data/ropsten/metadata/testnet_genesis.json

The error I'm getting is:

Fatal: failed to read genesis file: open /mnt/ethereum_data/ropsten/metadata/testnet_genesis.json: no such file or directory

Already checked and testnet_genesis.json is already in the right path. I appreciate any help.


texts: Lost my tokens - need help in figuring out what I did wrong

texts:
Can someone give me some advice on a transaction where I seem to have lost some of my tokens.
I’m new to this crypto world and now I’m wondering if I got myself into something I can’t manage.
I had several tokens being held on the exchanges, so I purchased a Ledger wallet and transferred most of them on October 8th from Kucoin to my Ledger wallet.
Two of my tokens could not be withdrawn from Kucoin since Kucoin was hacked and they suspended withdrawals on these two tokens.
They were ZRX and CRPT (ERC20) tokens.
All of the other 3 additional tokens I had on Kucoin were able to be withdrawn.
Two of which were ERC20 tokens, transferred correctly and went into my Ethereum account on Ledger as sub (token) accounts.
One of the transfers was Bitcoin and it went into my Ledger Bitcoin account without any problems.
Finally, on October 23rd the suspension was lifted and withdrawals were then allowed for ZRX and CRPT.
I proceeded to do the transfer and thought everything went okay until I noticed that CRPT didn’t show up in my Ledger wallet but ZRX did.
When I looked on my Kucoin account it showed that both ERC20 token transactions were successful and the tokens were all gone.
The Bitcoin transaction was also successful.
I now have a zero balance in my Kucoin account - which is what wanted.
The transaction details on Kucoin show that the “send to” address for both ERC20 tokens are the same and they match the address presented to me by my Ledger for my Ethereum account on my device.
Since they are both ERC20 tokens they both should have gone into the Ethereum account like all the many other tokens I sent to my Ledger back on October 8th (including transfers from other exchanges).
Both had the correct Ethereum address but ZRX made it but not CRPT.
I’ve waited a couple of days to see if they would show up but they haven’t.
I don’t know if I made a mistake in the transaction but if I did, I can’t figure out what it was.
There’s not a lot of money involved and if I’ve lost them, I can chalk it up to a lesson learned if only I knew what I did wrong.
I now hesitate to make any transactions for fear of a repeat of this episode, especially if it’s a large transaction.
Does anyone have an Idea of what might have happened and whether there’s any way or possibility that I can get my tokens back?
If there is a way, can you help walk me through the process?


texts: What can I use to interact with the Ethereum network from an Android device?

texts:
From my research, until I can build an Ethereum node on an Android device I’ll need to use a public API to interact with the network, such as BlockApps (http://www.blockapps.net/documentation#introduction). Is this correct or are there any other ways I could interact with the network?

And supposing I could build an Ethereum light-client on a mobile device eg using syng-im (https://github.com/syng-im) or similar could/would I have to interact with it using JavaScript? Or would it be dependant on the implementation?

EDIT: By 'interact' I'm referring to viewing balances, making transactions and creating accounts. However, I'm still interested in methods that would only allow a subset of these interactions.


texts: How to access data from web3.eth.Contracts.send() function?

texts:
If I run this chunk of code from my async function I will get a transaction receipt as an output:

const response = await contract.methods.recoverAddr(hex_msg,
v_decimal,r, s).send({from: accounts[0]}).then(console.log);

Whereas if I run the same chunk of code but with a call() instead of send(), I will get an address which I wanted. My question is: how do I actually access that address in my send() method?


texts: txpool on private chain not working unable to submit txn from non-miner

texts:
I have a local test setup with 3 Geth nodes, of which 2 are miners (Clique) and 1 non-miner.

I noticed that submitted transactions are never synchronized with other nodes.

Consequently, on a non-miner, submitted transactions never make it to the blocks.

That can't be normal behavior with Clique, can it?

Startup commands:

Node1:
geth --identity node1 --datadir node1/ --syncmode full --port 30304 --rpc --rpcport 8545 --bootnodes "enode://c0f96309ca5918bd0de1b69a0f062a590c7877681d7d69a370f3174cc3f137f200e024e86482ed3718c074a4d70488e09b7ff154dc5210ee0e890773646a25d8@127.0.0.1:30304" --nat none --networkid 2640 --gasprice 1 -unlock 0xe148888d6a894101a39b84da4d5f24c97f0ba3bd --password node1/password.txt --mine console

Node2:
geth --identity node2 --datadir node2/ --syncmode full --port 30305 --rpc --rpcport 8555 --ipcdisable --bootnodes "enode://c0f96309ca5918bd0de1b69a0f062a590c7877681d7d69a370f3174cc3f137f200e024e86482ed3718c074a4d70488e09b7ff154dc5210ee0e890773646a25d8@127.0.0.1:30304" --nat none --networkid 2640 --gasprice 1 -unlock 0x9d6189a2082a9df61d432cf384cb1f606cea1528 --password node2/password.txt --mine console

Node3:
geth --identity node3 --datadir node3/ --syncmode full --port 30306 --rpc --rpcport 8556 --ipcdisable --bootnodes "enode://c0f96309ca5918bd0de1b69a0f062a590c7877681d7d69a370f3174cc3f137f200e024e86482ed3718c074a4d70488e09b7ff154dc5210ee0e890773646a25d8@127.0.0.1:30304" --nat none --networkid 2640 --gasprice 1 -unlock 0xd134a62fb3d349c8ba2991dfba48e091544a8a13 --password node3/password.txt console

The nodes are connected

(On Node1, Node2, Node3):

> net.peerCount
2

Blocks are being mined and synchronized

On Node3:

INFO [05-07|14:31:42] Imported new chain segment               blocks=1 txs=0 mgas=0.000 elapsed=0s      mgasps=NaN   number=2375 hash=8271c9…543b5e cache=0.00B
INFO [05-07|14:31:47] Imported new chain segment               blocks=1 txs=0 mgas=0.000 elapsed=0s      mgasps=NaN   number=2376 hash=9442d8…b5b467 cache=0.00B
INFO [05-07|14:31:52] Imported new chain segment               blocks=1 txs=0 mgas=0.000 elapsed=0s      mgasps=NaN   number=2377 hash=611ee5…02ba2e cache=0.00B

But if I submit a transaction on a non-miner Node3:

> personal.sendTransaction({from:'0xd134a62fb3d349c8ba2991dfba48e091544a8a13', to:'0xE0ca7d355F0CC6C1EECDA7Ce081353b7D87Aa1d7', value: 1},'redacted')
INFO [05-07|14:31:16] Submitted transaction                    fullhash=0x9d1f3fa3a4c0037daed01371bd57d2ca6876cdb3d088ec7917656f272ce6485d recipient=0xE0ca7d355F0CC6C1EECDA7Ce081353b7D87Aa1d7
"0x9d1f3fa3a4c0037daed01371bd57d2ca6876cdb3d088ec7917656f272ce6485d"

Then nothing happens.
The transaction remains in "pending" status forever:

> txpool.inspect
{
  pending: {
    0xD134A62fB3D349c8ba2991dFbA48E091544A8a13: {
      0: "0xE0ca7d355F0CC6C1EECDA7Ce081353b7D87Aa1d7: 1 wei + 90000 gas × 0 wei"
    }
  },
  queued: {}
}

Empty blocks are still coming in on Node3:

> INFO [05-07|14:31:17] Imported new chain segment               blocks=1 txs=0 mgas=0.000 elapsed=0s      mgasps=NaN   number=2370 hash=33498f…5077c1 cache=0.00B

On other nodes there are no pending transaction at all:

Node1, Node2:

> txpool.inspect
{
  pending: {},
  queued: {}
}

Why is this and how to get transactions working on a non-miner?

Running Geth/v1.8.3-stable-329ac18e/windows-amd64/go1.10


texts: How to convert a uint256 type integer into a bytes32?

texts: Since both types, uint256's and bytes32's space are 2^256. How to map an uint256 type integer into bytes32 type in Solidity ?