texts: Adding a web2 Landing Page (homepage) to a drizzle-react based web3 app (dapp)

texts:
I'm trying to create an ethereum dapp using create-react-app & drizzle Hooks. My dapp requires the landing page (homepage) to not ask for metamask linking or drizzleProvider injection, and to keep it more of information page. subsequently from Homepage, it needs to be routed to one of the three pages - memberPage, inviteReceivedPage, inviteNotReceivedPage - all of which requires metamask linking to get the user account address, and drizzleProvider injection. This is how my app.js currently looks like:
import React from "react";
import { HashRouter as Router, Route, Switch } from "react-router-dom";
import "./App.css";
import { Drizzle, generateStore } from "@drizzle/store";
import { drizzleReactHooks } from "@drizzle/react-plugin";
import drizzleOptions from "./configurations/drizzleOptions";
import Header from "./components/Header";
import Footer from "./components/Footer";
import PageNotFound from "./components/PageNotFound";
import HomePage from "./containers/HomePage";
import InviteNotReceived from "./containers/InviteNotReceived";
import InviteReceived from "./containers/InviteReceived";

function app() {
  console.log("inside app.js");

  let headerComp = <Header />;
  let footerComp = <Footer />;

  console.log("drizzleoptions: ", drizzleOptions);
  const drizzleStore = generateStore(drizzleOptions);
  console.log("drizzlestore: ", drizzleStore);
  const drizzle = new Drizzle(drizzleOptions, drizzleStore);
  console.log("Drizzle: ", drizzle);

  return (
    <Router basename={process.env.PUBLIC_URL}>
      <div className="App">
        {headerComp}
        <Switch>
          <Route exact path="/" render={() => <HomePage />} />
          <Route
            path="/invited/:inviteCode"
            render={({ match }) => (
              <drizzleReactHooks.DrizzleProvider drizzle={drizzle}>
                <InviteReceived inviteCode={match.params.inviteCode} />
              </drizzleReactHooks.DrizzleProvider>
            )}
          />
          <Route
            path="/no-invite"
            render={() => (
              <drizzleReactHooks.DrizzleProvider drizzle={drizzle}>
                <InviteNotReceived />
              </drizzleReactHooks.DrizzleProvider>
            )}
          />
          <Route
            path="/:inviteCode"
            render={({ match }) => (
              <drizzleReactHooks.DrizzleProvider drizzle={drizzle}>
                <HomePage inviteCode={match.params.inviteCode} />
              </drizzleReactHooks.DrizzleProvider>
            )}
          />
          <Route
            path="/member/:memberAddress"
            render={({ match }) => (
              <drizzleReactHooks.DrizzleProvider drizzle={drizzle}>
                <MemberPage memberAddress={match.params.memberAddress} />
              </drizzleReactHooks.DrizzleProvider>
            )}
          />
          <Route render={() => <PageNotFound />} />
        </Switch>
        {footerComp}
      </div>
    </Router>
  );
}

export default app;

The problem is this router setup will still ask for metamask linking in homepage. Could anyone please suggest the right way to route this setup? Thanks.


texts: How to validate proper implementation of ERC-1155 contract?

texts: I want to implement an ERC-1155 contract. Using TDD we would first write a test.  Which begs the question of is there a way to validate that your contract properly implements ERC-1155?


texts: Is the block.timestamp value in Solidity seconds or milliseconds?

texts:
I'm looking to use block.timestamp in one of my contracts and I want to know whether the block.timestamp is seconds like in Python or milliseconds like in Java or some other value?

Also, is it safe to use block.timestamp to check if 30 days is past since the last updated time or something like that?


texts: What are the rules on persisting old transactions?

texts:
If a new node joins the network and attempts a full sync, it requires all transaction information from genesis to build up its chain state. To do this the transactions it receives must be the originals (signed transactions from the sender account) in order to verifiably build the state. It retrieves this data from other nodes on the network.

My question is: How are old transactions maintained to be able to sync new nodes on the network without storing too much excess data?


texts:
I want to make use of OZ's PaymentSplitter contract. From the docs, I can understand that we need to pass it two arrays on initialization: One containing addresses and another one containing the respective number of shares of each address.

constructor(address[] payees, uint256[] shares_) Creates an instance of PaymentSplitter where each account in payees is assigned the number of shares at the matching position in the shares array. All addresses in payees must be non-zero. Both arrays must have the same non-zero length, and there must be no duplicates in payees.

How does this work in practice? Lets say I am collecting contributions from users and each contributors share simply corresponds to: individual contribution / total contributions
I came up with something like this:
uint public totalContributed;
mapping(address => uint) public contributions;
address[] contributors;

function contribute(uint _amount) external payable {

   if(!contributors[msg.sender].exists){
        contributors.push(msg.sender);
    }

   contributions[msg.sender] = contributions[msg.sender] + _amount;
   totalContributed = totalContributed + _amount;

   emit NewContribution(_eventId, msg.sender, _amount);
}

How can I create the two lists I need to initiate the PaymentSplitter contract? Obviously I have the contributors array containing all of the different addresses that sent money. For the second one, I would need a list of all the values inside of the contributions mapping. Is this possible or am I entirely on the wrong track here? Note that multiple contributions per address are possible.


texts: I don't see any environment when deployed ethereum on Azure

texts:
Just started with ethereum block chain and done with the theory part.

As part of my work I need to do a sample POC of SmartContract + Private Blockchain on Azure.

I created Ubuntu VM from "Ethereum Consortium Blockchain" hoping all the required environment will be preconfigured in the VM. I also created a account on ether.camp.

But when I opened the machine I see it empty, I cant find any environment related to ethereum as mentioned in this post.

How does the Microsoft Azure Ethereum Blockchain as a Service differ from the platform offered by Eris Industries?

The ether.camp account is having a single project created with a sample Contracts.

please help me on the following

  Creating a private block chain and setting up an environment.

  Creating a new project in ether.camp.

  Deploying or connecting these contracts to the private blockchain.

Any links which explain in detail will be very helpful.

Thanks in advance,
Mahesh Gupta P


texts: Is there any particular reason the position of the public/private keywords change depending on whether it's a function or variable?

texts: I fear it will be difficult for me to remember if this quirk of the language is arbitrary...


texts:
I am running a private PoA network and am wondering if I should make the first node a bootnode or just use static-nodes or trusted-nodes instead?

Is there any benefit to having a bootnode in a consortium or is it simply unnecessary?


texts: What is the standard length of words in the mnemonic phrase for various ethereum wallets ? I need to know this in order to decide what should be the choices given to the user while creating a ethereum wallet address by using bip39 library.


texts:
Hi I have MetaMask installed and Im working with the Remix IDE. I've looked everywhere but can't seem to work out how to add multiple accounts to here:

so that I can test transactions using a different ether account. At the minute I have to go into MetaMax change the account and then refresh the Remix window to show the new account. If I click on the drop down only 1 account shows.

Thanks


texts: How does Ethhash compare to mining algorithms used in other blockchains?

texts:
When it comes to mining, I'm more or less aware of how Bitcoin's simple SHA256 mining works, how Litecoin & similar attempted (and failed) to introduce ASIC-resistance with Scrypt, and how Ethereum seemingly managed to do it with ETHASH and its huge DAG. I've heard, though, that new coins aren't really using ETHASH variants, and there are many interesting alternatives floating around. To organize those in a single place, can anyone:

Define the main high-level characteristics of existing mining algorithms?

Explain how they compare with Ethereum's mining algorithm?


texts: new array with values when call a constructor

texts:
contract A  {
        function A(address[] _owners, uint _required) {
        }
    }

    contract B is A {
        function B()
          A(new address[](0),0)) { // Call something like that
        }
    }

    contract C is A {
       function C()
         A([0x123],0) { // and like that
       }
    }

Is is possible to call a super constructor with an initialized array ?


texts:
My token is fully minted and the contract is already deployed and the full amount has been distributed to several wallets.

I want to do a crowdsale for my tokens and I want to know how the best way to automatically transfer the tokens from my ICO contract to the wallet of the payer. Shall I store the tokens on the ICO contract address? How can I transfer the tokens from my ICO contract to the contract of the payer? Any examples as all I can find are mintable token contracts.


texts: What are the requirements for contributing a pull request to the Ethereum web3.js repository?

texts:
I would like to make a pull request to the web3.js repository (https://github.com/ethereum/web3.js). Are there any requirements, guidelines, etc.
I haven't been able to find any information regarding contributions or a developers guide for web3.js, unlike go-ethereum (https://github.com/ethereum/go-ethereum/wiki/Developers-Guide)


texts: Where the Smart Contract deployment charges goes?

texts:
I'm newbie to Ethereum, and finding answers of some questions that I have.
I have learned about SC deployment that deploying the contract cost 0.01072934 ether, or about $3.21 USD

So, where that cost goes? it that goes to miners? or anywhere else?


texts:
I successfully deployed to ROPSTEN a very simple ERC20 Token Contract - the code for which I copy-pasted from OpenZeppelin's GitHub repo.

-I used remix to do this (see screengrab below)

-I'm 99.9% sure the code is perfectly fine because it's from OpenZeppelin - plus, as mentioned, the compilation & deployment went smoothly and without errors.

However, every time I try to do a simple Token Transfer from one account to another using the contract's transfer function, a window pops up with the following warning:

If I go on and tap on the "Send Transaction" button anyway, I do indeed get an error - and the transfer fails.

Checking the transaction on etherscan.io, it looks like this:

My question is simply this: what's going on?
I did everything correctly - why can't I do a simple transfer?

(The contract is sitting on Ropsten at the following address:
0xdce9f7c049d37414da4a3b4d11f8d1618b2c6dcc)

Here's what my Remix window is looking like:

And here's the Contract Code:

pragma solidity ^0.4.24;

import "./ERC20.sol";

/**
 * @title SimpleToken
 * @dev Very simple ERC20 Token example, where all tokens are pre-assigned to the creator.
 * Note they can later distribute these tokens as they wish using `transfer` and other
 * `ERC20` functions.
 */

contract POPCoin is ERC20 {

  string public constant name = "POPCoin";
  string public constant symbol = "POPC";
  uint8 public constant decimals = 3;
  uint256 public actualNumber = 0;

  uint256 public constant INITIAL_SUPPLY = 100000000 * (10 ** uint256(decimals));

  /**
   * @dev Constructor that gives msg.sender all of existing tokens.
   */
  constructor() public {
    _mint(msg.sender, INITIAL_SUPPLY);
    actualNumber = INITIAL_SUPPLY / (10 ** uint256(decimals));
  }

}


texts: Does MultiSig wallet's function follows any Token Standard i.e ERC223?

texts: Does MultiSig wallet may include functions like increaseSupply, decreaseSupply and functionality like blackList addresses?


texts:
I tried using require method in solidity in the following way:

require(validate(personName),"Error: Invalid Person")

In this case i am checking if a person is already added to my person list. If not then display the error message in console "Invalid Person".
Now, my problem is when I run the function with valid name I get no error.
But incase of invalid person name, it displays:

Error: VM Exception while processing transaction: revert
    at XMLHttpRequest._onHttpResponseEnd (/usr/local/lib/node_modules/truffle/build/webpack:/~/xhr2/lib/xhr2.js:509:1)
    at XMLHttpRequest._setReadyState (/usr/local/lib/node_modules/truffle/build/webpack:/~/xhr2/lib/xhr2.js:354:1)
    at XMLHttpRequestEventTarget.dispatchEvent (/usr/local/lib/node_modules/truffle/build/webpack:/~/xhr2/lib/xhr2.js:64:1)
    at XMLHttpRequest.request.onreadystatechange (/usr/local/lib/node_modules/truffle/build/webpack:/~/web3/lib/web3/httpprovider.js:128:1)
    at /usr/local/lib/node_modules/truffle/build/webpack:/packages/truffle-provider/wrapper.js:134:1
    at /usr/local/lib/node_modules/truffle/build/webpack:/~/web3/lib/web3/requestmanager.js:86:1
    at Object.InvalidResponse (/usr/local/lib/node_modules/truffle/build/webpack:/~/web3/lib/web3/errors.js:

instead of showing "Error: Invalid Person".
Can any one tell me what I am doing wrong here.


texts: How to store hash of an Excel file in Blockchain?

texts:
I'm sorry if this question does not seem to be logic.

I want to store hash of an Excel file in Blockchain by following function :

//byte fileHash;
event LogsetFileHash(byte _hashValue);

    function setFileHash(byte hashValue) {
        emit LogsetFileHash(hashValue);
        //fileHash = hashValue; // In case storing hash value in a variable is NOT expensive, we store hash in a variable, otherwise, we save it only as an event log.
    }

The question is how can I use Mathematical and Cryptographic Functions to convert the content of my Excel file to a hash value, regarding this fact that the content of an Excel file is not a string/text like a pdf file.

In fact what is not clear for me is that how to use one of this function like : keccak256(...) returns (bytes32) or sha256(...) returns (bytes32) to return _hashValue variable ? And also which one is better to use ? (if there is a difference in size of hash.)


texts: how to send erc20 token without using smart contract abi?

texts:
How to transfer erc20 token without using contract or contract abi?

The below script i have used to create Signed Raw Transaction to send Ether(ETH).
How can i create Signed Raw Transaction to send erc20 token with the same script by doing some modifications
what modifications are actually required i want to know and also i do not want to use smart contract abi.

var rawTx = {
  nonce: '0x1a',
  gasPrice: '0x4a817c800',
  gasLimit: '0xc350',
  to: '0x73F7Ced8cc9D27DC426210c32fc6d0a40f941eE1',
  value: '0x2386f26fc10000',
  data: '0x0',
  chainID: 4
}
var cTx = await new EthereumTx(rawTx, { 'chain': 'rinkeby' });
cTx.sign(privateKey);
var serializedTx = await cTx.serialize();
var cTxHash = await web3.eth.sendSignedTransaction('0x' + serializedTx.toString('hex'))


texts: Is the gas-limit as seen on ethstats measured in wei?

texts: Simple question but I can't seem to find the answer online


texts: Retrieve Mdex.com exchange rates for token pair [Huobi Eco Chain]

texts: After long Telegram conversations I have found out that MdexSwap uses a secret formula to calculate their token exchange rates on their swap platform. Unlike Uniswap they also don't really have an API, SDK or any other documentation for developers at least what I have found out after intense researching for more than a week. I have found their Github and some kind of API but that's it and as said before it doesn't make any sense to me...


texts: Need a decent alternative to define json interface in web3.eth.Contract function

texts:
I created a file called contract.js with the abi code as follows.

var contract_abi = [{
        "constant": true,
        "inputs": [
            {
                "name": "_serviceproducerDescription",
                "type": "string"
            }
        ],
        "name": "retrieveProducerView",
        "outputs": [
            {
                "name": "",
                "type": "address"
            },
            {
                "name": "",
                "type": "string"
            }
        ],
        "payable": false,
        "stateMutability": "view",
        "type": "function"
    },
{...},
{...},
]

and trying to use it in app.js file

var contract = require("./contract.js");
var PublishServiceContract = new web3.eth.Contract(contract.contract_abi,"0x..");

If i try to read this way, I get the below error.

  Error: You must provide the json interface of the contract when
  instantiating a contract object.

But it works fine if I use the total abi I get from remix in this call

var PublishServiceContract = new web3.eth.Contract([{...},{...},{...}],"0x..");

I don't understand the difference between the two and reason for failure. Can someone help me please.

Thanks!!!


texts: Correctly address Smart Contract storage address using web3js 1.0.0 library functions

texts:
A short while ago, I found a fantastic Medium article explaining Smart Contract storage.

The examples in this article have helped me to understand how to read a Smart Contract's storage values from the command line / console.

However, with the version 1.0.0 of web3js going into Beta - and the NPM version of web3js being installed by default being the 1.0.0 Beta version, I thought that I would upgrade my code using the information from the aforementioned article to the new library.

The problem is that I can't replicate the same behavior of web3.sha3 using the new version of the library; web3Utils.sha3.

To clarify, here are some examples - starting with the output that I get from the stable, but pre-V1.0.0 web3.sha3 function and then from the new, Beta version of the web3js library:

To give you some context, the test is based on accessing the mappings data in this contrived Smart Contract:

pragma solidity ^0.4.0;

contract StorageTest {
    mapping(address => uint256) public storedData;

    function addDataToMapping(address account, uint256 amount) public {
        storedData[account] = amount;
    }
}

The way that I determine how to access the mapping's data for the address 0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1 is by using the following pre-V1.0.0 web3js call:

web3.sha3("00000000000000000000000x90F8bf6A479f320ead074411a4B0e7944Ea8c9C10000000000000000000000000000000000000000000000000000000000000000", {"encoding":"hex"})

This results in the hash value

0xbbf27a261d686d37ad5c6299e09a73a2a829c9c10eaf9c5c19e6ff2488e52f20

Now, if we simply port this over to the V1.0.0 library then the code looks like this:

web3Utils.sha3("00000000000000000000000x90F8bf6A479f320ead074411a4B0e7944Ea8c9C10000000000000000000000000000000000000000000000000000000000000000", {"encoding":"hex"})

However, this results in the following (different) hash being output:

0x02d38ce98b8dae9d7cc32b64bb52580b4989cb56d07114b95037da4af5f500cf

I tried removing the {"encoding":"hex"} parameter (because this isn't mentioned in the documentation:

web3Utils.sha3("00000000000000000000000x90F8bf6A479f320ead074411a4B0e7944Ea8c9C10000000000000000000000000000000000000000000000000000000000000000")

But unfortunately, I still get the same output:

0x02d38ce98b8dae9d7cc32b64bb52580b4989cb56d07114b95037da4af5f500cf

The documentation mentions a web3Utils.soliditySha3 function that sounded like it might do the trick, so I switched this function call in instead:

web3Utils.soliditySha3("00000000000000000000000x90F8bf6A479f320ead074411a4B0e7944Ea8c9C10000000000000000000000000000000000000000000000000000000000000000", {"encoding":"hex"})

This time I got a different value, but it is not the one that I am looking for:

0x0780d226e6d7ac5576d20e78b8c3a2122ace468d419adefef1e79c49d7f4116f

I also tried removing the {"encoding":"hex"} parameter (because this also isn't mentioned in the documentation:

web3Utils.soliditySha3("00000000000000000000000x90F8bf6A479f320ead074411a4B0e7944Ea8c9C10000000000000000000000000000000000000000000000000000000000000000");

But this just results in the same, incorrect, value as the web3Utils.sha3 function calls:

0x02d38ce98b8dae9d7cc32b64bb52580b4989cb56d07114b95037da4af5f500cf

I have also tried various permutations of the "Any type, or an object with {type: 'uint', value: '123456'}" parameter format:

web3Utils.soliditySha3({type: 'string', value: "00000000000000000000000x90F8bf6A479f320ead074411a4B0e7944Ea8c9C10000000000000000000000000000000000000000000000000000000000000000"})

And yet I still can't get the correct value.

Does anyone know how to correctly address a mapping or struct storage address using the latest web3js library functions?


texts:
How can I combine Quorum and Zero Knowledge Range Proofs

I have 20 years of experience at java JEE coding, and 10 years in devops as well,
but no experience with blockchains, or the Go language.

I want to setup a cluster of Quorum blockchain nodes, including the features
provided in ING bank's zkproofs project. I want to be able to complete transactions
where a Prover and Verifier can interact. The Github project provides zero knowledge range proofs
and zero knowledge set membership.

I don't think I'll have much problem bringing up Quorum, but the documentation in the github
project https://github.com/ing-bank/zkproofs is limited! How can I come to understand
how to put the zkrp code with the Quorum nodes, to realize an integrated system? Any tutorials
that would help out there somewhere?


texts: Etherscan contract verification: invalid constructor arguments


texts: Will the introduction of sharding have an effect on the functionality of currently deployed smart contracts or the EVM?

texts:
Is there any risk the the hard fork required for sharding or Plasma to take effect on the Ethereum network will cause compatibility issues for contracts already deployed?

Will the protocol in place whenever sharding is enacted be backwards compatible with current contracts (such as Tokens, etc).

Thanks for any help. I'm struggling to understand how it will effect this aspect of Ethereum.


texts: HELP! Calling another contract not working

texts:
Truffle v4.1.8 (core: 4.1.8)
Solidity v0.4.23 (solc-js)

My Token

contract ERC20Token {
    function contractTransfer(address from, address to, uint tokens) public returns (bool success) {
        // bla.bla.bla....
        return true;
    }
}

My Contract which can transfer the token

import "./ERC20Token.sol";

contract MyContract {
    ERC20Token public Coin;

    constructor (address coin) {
        Coin = ERC20Token(coin);
    }

    function Test(address from, address to, uint amount) public {
        // bla...bla..lba...
        Coin.contractTransfer(from, to, amount);
    }
}

The code above was simplified. Security is not a concern for this question.

The code used to work until I have upgraded truffle to 4.1.8 and solc = 4.23.

Previously was using truffle = 4.1.3 and solc = 4.19

I can't invoke contractTransfer from MyContract. May I know what had changed?


texts: Problems calling a function with a bidimensional Array

texts:
Apologies in advance about my English but I'm still learning :)

I'm doing some tests with a contract that has this concrete function

function createBuyOrder(
    address token,
    uint tokensTotal,
    uint8[] exchanges,
    address[5][] orderAddresses,
    uint[6][] orderValues,
    uint[] exchangeFees,
    uint8[] v,
    bytes32[] r,
    bytes32[] s
  )

as you can see, I need to pass 2 nested arrays to the function, but when I do it in remix I get this error: "Error encoding arguments".

The arguments im passing are:

token: "0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359"

tokensTotal: 1233

exchanges: [1]

orderAddresses:

[["0x0004e79c978b95974dca16f56b516be0c50cc652"], ["0x0000000000000000000000000000000000000000"],["0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"],["0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359"],["0xa258b39954cef5cb142fd567a46cddb31a670124"]]

orderValues:

[[20000000000000000000], [13826078276400000000000],[0],[0],[1526956201,[44981771799304801685616814501018498376938501293606517488617232210966542022274]]

exchangeFees: [0]

v: [27]

r:["0xde7ff8f42676ba3bb5986f869ac00b6aa061f41a281b943f9e8c88c3c17cd4fa"]

s:["0x2628b4330c1cb3e3ee6be748cc5c55ed19374a016063ebd9a0b1c77fd91e8024"]


texts: Unable to use ecrecover in solidity to recover address used to sign a message, simply returns 0x0 address

texts:
I do the following in geth:

var msgHash = web3.sha3("hello")
var signature = eth.sign(eth.accounts[0], msgHash)
var r = signature.slice(0,64)
var s = "0x" +signature.slice(64,128)
var v = signature.slice(128,130)

  r = signature.slice(0,64)
  "0x6d49c891d29b33c292232f690c9972e17e0dbead7d4fc446bb4ce5892f0e55"
  s = signature.slice(64,128)
  "a22c9f3c20a7f0bc90666d1d1c6f269658a0ccd56b1db1812671e23331d8ad2c"
  v = signature.slice(128,130)
  "52"

I then call the following solidity code

function verify(bytes32 msgHash, uint8 v, bytes32 r, bytes32 s) public {
    bytes memory prefix = "\x19Ethereum Signed Message:\n32";
    bytes32 prefixedHash = keccak256(prefix, msgHash);
    a = ecrecover(prefixedHash, v, r, s);
}

Which returns the following:
0x0000000000000000000000000000000000000000

Absolutely stumped by this, I've taken a look at the following threads to no success:

ecrecover from Geth and web3.eth.sign


texts: How are state channels being implemented (MetaMask?)

texts:
I've been trying to get MetaMask to produce a signature for a sha3 hash that I can verify in solidity. I've tried eth_sign, personal_sign, eth_signTypedData, and I've had 0 success.

My test suite runs fine (Truffle), but I can not for the life of me get MetaMask to play nice, and I can't find a working example anywhere.

What do I do?


texts: Calling function from web3, getting transaction hash but transaction status fail

texts:
I have a contract deployed on rinkeby with function name userexist();

Now, calling this function from web3 :

Web3.eth.defaultAccount = '0x262b76dF1dCb6542AA4a19296A824F0fDD1B4B04';

Web3.personal.unlockAccount(Web3.eth.defaultAccount,'******', 15000)

var getData = contractinstance.userexist();

var transaction = Web3.eth.sendTransaction({
    from: Web3.eth.defaultAccount,
    to: '0x3FCc01A2d64978962c144d67E52897AAaf69d1C7',
    data: getData,
    gas: 90000
});

console.log(transaction);

Getting result as  :
0x9ea36225341791b471afd309658a146a0881bee6c0a00d1d52f837c78df624ea

Now when I check this on rinkeby
https://rinkeby.etherscan.io/tx/0x9ea36225341791b471afd309658a146a0881bee6c0a00d1d52f837c78df624ea

It show transaction status as failed.....

I tried twice but getting same error

Can anyone help please .....

Thanks In Advanced


texts: Is it conventional to host your dapp on a subdomain (e.g. app.uniswap.org), and why?

texts: I've noticed the design pattern of having an enter app button from the home/landing page which opens the dapp in a new tab is quite common. This is something that I don't see in Web2 design. Is there a reason for this?


texts: Solidity calldata for an array of structs

texts:
I'm trying to create the calldata offchain for an on-chain low-level call to a method that accepts an array of structs as an argument. I'm not sure how to encode the calldata for this.

Here's a simplified version of what I'm trying to call

Contract A:

    enum Operation {
        BUY,
        SELL
    }
    struct OrderItem {
        address token;
        uint256 weightIfBuyAmountIfSell;
        uint256 minEthIfSell;
        uint256 deadline;
        Operation op;
    }
    function placeOrder(OrderItem[] memory _order) public payable{
        // handles the OrderItem[]
    }

Contract B:

    function execute(address dest, bytes calldata _calldata) external {
        // The below function will call the placeOrder method of contract A
        (bool success, ) = dest.call(_calldata);
    }

I need to know how to (off-chain) create the _calldata parameter for contract B

Here's what I've got so far:

// the next two lines are the first part I'm unsure of, but here's my best guess
let functionCallTypes = 'tuple[]'
let callFunction = 'placeOrder' + '(' + functionCallTypes.join() + ')'
let callFunctionHash = web3.utils.sha3(callFunction)
let callFunctionSignature = callFunctionHash.substring(0, 10) // 0x + 4 bytes

//The next line lines of web3 code is the second bit I'm unsure about
let functionCallParams = [{I'll include the actual orders here}]

// Once I've got those two variables properly set, the below code should finish the job :)
let encodedCallParams = web3.eth.abi.encodeParameters(functionCallTypes, functionCallParams)
let data = await web3.utils.toHex(callFunctionSignature + encodedCallParams.substring(2));


texts: Failed to call web3.utils.sha3 on truffle console

texts:
I try to call

web3.utils.sha3('234');

on truffle console. However I got an error:

TypeError: Cannot read property 'sha3' of undefined
at evalmachine.<anonymous>:1:11
at ContextifyScript.Script.runInContext (vm.js:35:29)
at Object.runInContext (vm.js:89:6)
at Console.interpret (C:\Users\aa\AppData\Roaming\npm\node_modules\truffle\build\cli.bundled.js:202201:17)
at ReplManager.interpret (C:\Users\aa\AppData\Roaming\npm\node_modules\truffle\build\cli.bundled.js:202917:18)
at bound (domain.js:280:14)
at REPLServer.runBound [as eval] (domain.js:293:12)
at REPLServer.<anonymous> (repl.js:538:10)
at emitOne (events.js:96:13)
at REPLServer.emit (events.js:188:7)

Does this mean web3.utils.sha3 has not supported yet?


texts:
This question is related to this one or this one. There is a tutorial here that shows some filtering examples but it doesn't get into transaction level granularity. Can we query the block chain by transaction and process specific transactions asynchronously?

For example, this code goes through blocks starting and ending with a given block number and displays each transaction to or from a given address:

function getTransactionsByAccounts(myaccount, startBlockNumber, endBlockNumber) {

  console.log("Searching for transactions to/from account \"" + myaccount + "\" within blocks "  + startBlockNumber + " and " + endBlockNumber + "\"");

  for (var i = startBlockNumber; i <= endBlockNumber; i++) {

    var block = eth.getBlock(i, true);
    if (block != null && block.transactions != null) {
      block.transactions.forEach( function(e) {
        if (myaccount == "*" || myaccount == e.from || myaccount == e.to) {
          console.log("  tx hash          : " + e.hash + "\n"
            + "   nonce           : " + e.nonce + "\n"
            + "   blockHash       : " + e.blockHash + "\n"
            + "   blockNumber     : " + e.blockNumber + "\n"
            + "   transactionIndex: " + e.transactionIndex + "\n"
            + "   from            : " + e.from + "\n"
            + "   to              : " + e.to + "\n"
            + "   value           : " + e.value + "\n"
            + "   gasPrice        : " + e.gasPrice + "\n"
            + "   gas             : " + e.gas + "\n"
            + "   input           : " + e.input);

            // Do something asynchronously with the transaction:
            call_async_method(e); // <== HOW CAN WE ADD THIS AS A PROMISE?
        }
      })
    }
  }
}

How can we process a transaction asynchronously (as shown in the code)? possibly using promises and the filters defined in web3.js.


texts:
I've written the following contract

contract Catalog{
    address[] internal array;

    function pushItem(address _el) external{
         array.push(_el);
    }

    function getArray() external returns(address[]){
         return array;
    }
 }

I've deployed it on a local Javascript VM with Remix. Then I've called pushItem(0x.....) but, when I invoke getArray() the following output is returned:

error: Failed to decode output:
 TypeError: Cannot read property 'length' of undefined

Any idea why and how to solve this problem?


texts: My Mist wallet shows Im synced but when I go to the chaindata folder it is about 130000 behind.Does anyone know why this is. I do not seem to have a problem with geth or mist but curious why the chaindata is so far behind.


texts: What is the authorization for any technical central action in Ethereum system?

texts:
When, after fully reviewing, pull requests management and a detailed discussions on github and so on, it arrives the moment in which someone must take into his hands the technical intervention on the code and/or on the blockchain or whatever... what is the mechanism used to authorize technical operators to implement the deiberated changes?

What is the mechanism that prevent the person(s) who act on the overall system to, let’s say as example, add 100 ether on some accounts or to move the balance of tokens or whatever?

In other word: how the community controls the technical administrators of the community?


texts:
This is my contract

pragma solidity ^0.4.20;

contract Test {
    struct TestStruct {
        bytes32 name;
        mapping(uint => address) tesMapping;
    }

    TestStruct[] public testStructs;

    function Test(bytes32[] names) {
        for (uint i = 0; i < names.length; i++) {
            testStructs[i] = TestStruct(names[i]);
        }
    }
}

I'm using web3 v1.0. I create a new contract instance with:

c = new web3.eth.Contract(abi, from, {
    data: data
});

where abi, from and data are defined in the right way previously.

When I try to estimate the gas needed for deploy in this way:

c.deploy({
    data: data,
    arguments: myArgs
}).estimateGas(console.log);

I get this error:

Error: Returned error: VM Exception while processing transaction: invalid opcode

If I delete the body of the constructor (I leave the constructor empty), I get null.

Is there something wrong in the for loop in the constructor?


texts: Removing / Unlisting Smart Contract from Etherscan.io

texts:
I've been creating several smart contracts for testing purpose, with the same Name, Symbol, Supply, & etc. And I'd like to remove/unlisting those smart contracts from etherscan because it is spammed the etherscan.io

EDIT:
All of those dummy smart contracts has been created and didn't implemented with delegatecall or callcode


texts: Is anyone forking OpenBazaar for Ethereum? OpenBazaar is a Bitcoin marketplace, and the OpenBazaar developers have expressed no interest to integrate any currencies other than Bitcoin.


texts: Read args object from particular block transaction in truffle console.

texts:
Hi I have question on how to read args from specific block transaction that are passed when event was called. I have triggered an event, my block is created and i got transaction tx. In the ' Logs: ' segment I have 'args:' (on the bottom of image) which are stated as
'[object]'. I want to read/print arguments on truffle console that are passed to this votedEvent if it is possible. What are the commands and what is the logic behind it.

I'm sorry but I have copied an image because I consider this to be more readable and much easier for me than formating. Thanks.


texts: How to integrate smart contracts with android app using web3j

texts: I want to integrate smart contracts with the android app. I wrote a simple smart contract and I want to call that smart contract from android app. For example, in UI part of Android, I put one Edittext and one button. So whenever the user clicks the button then the functions of the smart contract executed. How to connect smart contract with android using web3j.


texts: Why are the transfer and approve functions payable in the ERC-721 spec?

texts:
In the ERC-721 spec interface, the functions safeTransferFrom, transferFrom and approve all have the payable modifier. What is the reason for this? As far as I can tell, none of these functions require it, and I'm not sure what I should be doing with the value.

function safeTransferFrom(address _from, address _to, uint256 _tokenId, bytes data) external payable;

function safeTransferFrom(address _from, address _to, uint256 _tokenId) external payable;

function transferFrom(address _from, address _to, uint256 _tokenId) external payable;


texts: Infinite gas estimate caused by Internal function type

texts:
When I flag a simple function with the type internal, remix throws an infinite gas estimate warning. Without this type, everything is fine. Please, do you know why?

function half(uint a) {
          uint b = a/2;
          //...
}-> Gas estimate for "half(uint256)": "230"

function half(uint a) internal {
          uint b = a/2;
          //...
} -> Gas estimate for "half(uint256)": "infinite"


texts: Cannot assign value to a variable in truffle console and other problems

texts:
I'm trying to do very basic things with Truffle 3.4.6 console. I've been able to successfully compile and migrate a contract and access its contents using both:

CoinCrowdsale.deployed()
CoinCrowdsale.at("0x327d1b04ea59035626438b84ea03a543d38662e0")

But then, there're things from the examples I cannot do. For example, assign a value to a variable:

var crowdsale = CoinCrowdsale.at("0x327d1b04ea59035626438b84ea03a543d38662e0")
Truffle v3.4.6 (core: 3.4.6)
Solidity v0.4.13 (solc-js)

The result of the assignation is the software version?? Of course, it's not been assigned at all:

crowdsale
Please specify the type of item to create. Example: truffle create contract MyContract

I've got more problems:

> truffle(development)> CoinCrowdsale.deployed().then(inst => {
> crowdsale = inst }); undefined

and then, again, inst is never assigned to crowdsale variable nor can access it in the console.

What am I doing wrong? Truffle docs are not helping so much...

Thanks in advance


texts: How to get two points (x, y) from an encoded pubkey?

texts:
this gives a valid address from two points;

address(uint256(keccak256(abi.encodePacked(point[0], point[1]))) & 0x00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);

but does that mean that if you are given just an address, you cannot get the two points that were used to generate it (because of the hash function)?


texts: How can we conserve disk space or compress the blockchain?

texts: The blockchain is eating into my macs disk space. Will there be a way in the future to compress it or redirect to an external hard drive?


texts: Solidity SafeMath library best practice use cases

texts:
I understand why and how to use the SafeMath library.
However, I was wondering if there is a kind of best practice guide how and when to use the library and in which cases you don't have to.

From a safety aspect it would be fail resistant to just use it on any any any operation, right? Still there are so many very high quality smart contracts which are still only using the library in some cases but not all. I guess it's for gas efficient purposes?

Is there any recommendation or best practice guide when and when not to use the SafeMath library?


texts: Why does MyEtherWallet freeze upon decrypting my geth-generated keystore file

texts:
First of all, I am very new to all of this. I did some searching for an answer by myself, but could not find an answer or someone with the same problem as me.

I (mostly for fun) tried GPU mining using geth and ethminer with a 2GB AMD graphics card on Ubuntu today and I am currently in the process of downloading the blockchain. I also created a wallet using geth account new. I entered a password and it spat out an encrypted keystore file.

I tried uploading said file to https://myetherwallet.com/ to access it and it asked me to enter the password. I did and hit "Unlock". Upon doing that, Firefox stopped working for a few seconds, until I get an error message telling me that the following script is unresponsive: https://www.myetherwallet.com/js/etherwallet-master.js:95929

EDIT: I solved it a few minutes after posting this. It's an error with Firefox on Ubuntu. I tried Chrome on Ubuntu and it worked! Hope this helps anyone running into the same problem.


texts: Do intermediate memory variables cost gas?

texts:
Example without an intermediate variable:

uint startTime = 9;
uint allowedTime = 7;

require(now > startTime + allowedTime);

Example with an intermediate variable:

uint startTime = 9;
uint allowedTime = 7;

uint deadline = startTime + allowedTime;

require(now > deadline);

Obviously those two blocks above are functionally equivalent, but the latter one introduces an intermediate variable to increase readability. I would expect the intermediate variable to cancelled out when source code gets compiled, so those two example should produce the same bytecode. If this is the case there should be no extra gas cost for usage of an intermediate variable.

Why bother? Those examples above are simple but in real situations sometimes intermediate variables are extremely useful to reduce congnitive load of reader (readible code -> bug-free code -> secure contract). So I wan't to use it if it's free gas-wise.

Now comes the question: Do intermediate variables get cancelled out by Solidity compiler and cost no extra gas? Or Solidity compiler is not that smart yet?


texts: Which method is efficient to log data in blockchain? Send an event via smart contract or send data in a transaction without value?

texts:
I want to log data in Ethereum block-chain. It is obvious that we can create a smart contract that emits events and retrieve data from it.
But is sending a transaction with data but no ETH value (just gas but no ETH) more efficient than deploying a contract that emit events?
I would like to from the following perspectives:

Cost - Which of the 2 methods is cheaper?
Retrieval - Is any method provides faster data retrieval than the other?
Deletion - Does deleting smart contract data deletes the events as well?

Would love to know some answers for the above.
Thank you! :)


texts: Running out of Gas while deploying contract via web3.js

texts:
// contract is storing ABI
 var instance = contract.new(
    "0x12", // bytes32
    "0x12", // bytes32
    [],   // array of addresses
    11,  // uint
    11,  // uint
    "0x0aB245c1d6Da5e7CAe0c9607b5bFA2747574c2b1", // another contract address
    "0xb513bF478caD09db7754A6139616ba5514f3a068", // another contract address
    {from:web3.eth.defaultAccount, gas : 5000000}, function(error, result){
  if(!error){
    console.log(result);
  } else {
    console.log(error);
  }
})

I am able to deploy my contract in remix and not via web3.js. i have increased the gas limit but nothing works.

The total number of arguments are also correct.
Basically, i have to pass arguments to constructor to deploy the Smart contract. That is why i have used "new"

P.S

function Product(bytes32 _name, bytes32 _additionalInformation,
      address[] _parentProducts, int _lon, int _lat, address _DATABASE_CONTRACT, address _PRODUCT_FACTORY) {
name = _name;
isConsumed = false;
parentProducts = _parentProducts;
additionalInformation = _additionalInformation;

DATABASE_CONTRACT = _DATABASE_CONTRACT;
PRODUCT_FACTORY = _PRODUCT_FACTORY;

Action memory creation;
creation.handler = msg.sender;
creation.description = "Product creation";
creation.lon = _lon;
creation.lat = _lat;
creation.timestamp = now;
creation.blockNumber = block.number;

actions.push(creation);

Database database = Database(DATABASE_CONTRACT);
database.storeProductReference(this);
 }


texts:
I'm new to Ethereum and I'm really confused. I am mining to my my Eth address and when I check my address at https://eth.nanopool.org/account/0xADDRESS I see how much ether I have mined so far. But when I check that same address in my GUI wallet on my Linux desktop 'Ethereum Wallet' it's showing 0.00 ETHER. Why is the same address showing 0.00 on the GUI desktop wallet but 0.05....... on the mining pool's website?

I don't remember if I got the address originally from CLI geth, https://www.myetherwallet.com/#view-wallet-info, or the desktop Ethereum Wallet.


texts: How to set params for eth_getLogs in order to query ERC721 burn event?


texts: Open Zeppelin crowdsale requires too much gas

texts:
EDIT: we spotted the mistake in the code, endtime = starttime

I deployed with truffle a subclass of zeppelin popular crowdsale

contract GorillaSale is Crowdsale {

  function GorillaSale(    uint256 _time_start,
                           uint256 _time_end,
                           uint256 _rate,
                           address _wallet)

    Crowdsale(_time_start, _time_start, _rate, _wallet)
  {

  }

  function createTokenContract() internal returns (MintableToken) {
    return new GorillaToken();
  }

}

contract GorillaToken is MintableToken {

  string public constant name = "Gorilla Token";
  string public constant symbol = "GRL";
  uint8 public constant decimals = 4;

}

The contract is deployed on ropsten at 0xae09A60d2Ccb4431856229fB7B68b948ce583264 but if I try to send ether from metamask or MEW to it I get a gas estimate for the transaction of 4.5M gas, which is huge and the transaction fails. Here an example of failed tx 0x86c2d36dc65e9e9f8e3b50a47a5f1619f9a2da0891c6327309c1ce97eb470e59

I suspect there is something strange and not related to the gas. I wonder how a crowdsale could possibly work with gas = 4.5M, in ropsten would be 30$ of fees.


texts: Create account on Ethereum using Nethereum C#

texts:
I have studied the documents for creating a new account using Nethereum..

var ecKey = Nethereum.Signer.EthECKey.GenerateKey();
var privateKey = ecKey.GetPrivateKeyAsBytes().ToHex();
var account = new Nethereum.Web3.Accounts.Account(privateKey);

I want to create the account on Geth to start with for testing and then will migrate this to Ethereum live.  For this I am initalising Web3 with a constructor:

public Web3 _web3;

        public BaseEthererumService()
        {
            _web3 = new Web3(Config.EndPointURL);  // Prod "https://mainnet.infura.io";
            // Geth "localhost:8545";
        }

What I want is to write a new address to Geth (or Ethereum in prod) and to receive a new contract address back..

I have also tried:

public async Task<string> CreateAccount()
        {

            var account = await _web3.Personal.NewAccount.SendRequestAsync("123");

            return account;
        }

But this bombs out without returning any form of address. And when I run at a CLI geth account list I don't get anything back...

I simply need to register a new account on the blockchain programmatically using Nethereum.Web3

Any help would be appreciated.


texts:
How can I steal from Vuln contract? I have made another contract to try to steal from Vuln but it always gives me an error. And I'm not sure how to send the money to my adrress.

contract Vuln {
    mapping(address => uint256) public balances;

    function deposit() public payable {
        // Increment their balance with whatever they pay
        balances[msg.sender] += msg.value;
    }

    function withdraw() public {
        // Refund their balance
        msg.sender.call.value(balances[msg.sender])("");

        // Set their balance to 0
        balances[msg.sender] = 0;
    }
}
contract ReentrancyAttack {
    Vuln target = Vuln(/* some addresss */);
    uint amount = 500 wei;
    uint maxwithdraw = 0;
   address payable theif = msg.sender;

   function depositamount() public payable{
        target.deposit.value(msg.value)();
     //   target.withdraw();
    }
    function withdrawamount() public payable{
     //   target.deposit.value(msg.value)();
        target.withdraw();
    }

     function () external payable{
        if (maxwithdraw < 5){
            maxwithdraw++;

            if (address(target).balance >= amount)
                {
                target.withdraw();
                }
        }
     }
}


texts: How to use swapExactETHForTokens in smart contract?

texts:
I want to use use swapExactETHForTokens in my smart contract, always fails transaction with error which is "execution reverted: UniswapV2Library: INSUFFICIENT_INPUT_AMOUNT".
This is my code.
pragma solidity ^0.6.2;

interface IUniswap {
    function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)
        external
        payable
        returns (uint[] memory amounts);
    function WETH() external pure returns (address);
}

contract MyDefi{

    IUniswap uniswap;

    constructor(address _uniswap) public {
        uniswap = IUniswap(_uniswap);
    }

    function tastSwapExactETHForTokens(
        uint amountOut,
        address token,
        uint deadline
    ) external payable {
        address[] memory path = new address[](2);
        path[0] = uniswap.WETH();
        path[1] = token;
        uniswap.swapExactETHForTokens(
            amountOut,
            path,
            msg.sender,
            deadline
        );
    }

}

I tried to swap DAI token in rinkeby network and I got an amountOut argument from the etherscan website.
https://rinkeby.etherscan.io/address/0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D#readContract
Does anyone help to solve my problem?


texts: Running external script using truffle to interact with my contract

texts:
Is it common to run external scripts with truffle? I keep seeing posts online with long js scripts to interact with contracts, but had no clue how people were running them outside of the console, which only accepts one-liners.

Anyway, I used the documentation to find out that my external script can be executed like this

truffle exec ./scripts/script.js

However, I'm getting an error that HodlEthereum is not defined when I try to run it.
The documentation states that I must use the module.exports encapsulation of my script. I've pasted what I have below:

module.exports = function(callback) {
    console.log(HodlEthereum.at("0x82d50ad3c1091866e258fd0f1a7cc9674609d254"));
}


texts: How to create an ethereum accounts for my own token using node js web3

texts:
I have created my own token and now I want to create accounts for clients where they stock tokens using node js express.But I have no idea how to generate accounts' address !
Can anyone help me please even with useful linkS to start :)
Here is the  code that I have written (the code compiled well but no address is returned)

var mytoken= MyContract.at(contractAddress);

//accounts creation
   var options = {
      host: '/home/yosra/Bureau/mynetwork/ResponsableRH/geth.ipc',
      ipc:true,
      personal: true,
      admin: false,
      debug: false

          };

   var web3 = web3_extended.create(options);

   var newaccount=web3.personal.newAccount("password",function(error,result){

       if(!error){
          console.log(result);
                 }
    });


texts: Ethereum Solo Mining - Adding additional miners to the rig

texts:
I am new to mining and have setup my test mining setup in EC2. I know that this is not profitable but doing to understand how this works.

I have 2 EC2 instances where in the first instance, I am running geth which syncs block chain. Also, in the same instance I am using ethminer and doing GPU based mining. In this instance, I have created a geth account.

In the second EC2 instance, I am only running ethminer and is connected to the first EC2 instance's geth farm. I can see both the miners doing at around 36 MH/s.

My question is - Am I doing this correctly? Also, is it required for me to setup an account in the second ec2 instance? Currently, I have not added any account in that instance. I am assuming that both the miners are contributing the account that I defined in my first Ec2 instance. Correct me if I am wrong here.

Thank you.


texts: Losing connection between nodes on private network

texts:
I have 3 nodes running on a private network.

After asking this question, I've manually added node1 as peer to node2 and node3, so my network looks like this:

                 _______
     ---------> | node2 |
    /           |_______|
   v
 _______
| node1 |
|_______|
   ^
    \            _______
     ---------> | node3 |
                |_______|

I've left the nodes running through last night, but around 10 PM (BRST), node2 and node3 stopped listening to node1 (admin.peers was empty), while node1 was still connected to both of them (admin.peers contained 2 items), but not getting any interaction.

Is it possible that this is a problem with Ethereum protocol or would it be something else?

Edit:

I'm running the nodes in the same physical machine, but in different VMs. Those VMs have Ubuntu 12.04 installed.

The VMs are running over a CentOS with VMWare vCenter.


texts: Error in code Expected pragma, import directive or contract/interface/library definitio

texts:
I am getting the below error when i compile the below code. Using remix compiler version 0.5.11
****browser/TodoList.sol:7:2: ParserError: Expected pragma, import directive or contract/interface/library definition.
 struct Task {
 ^----^****

pragma solidity >=0.5.0 <0.6.0 ;

contract TodoList {
    uint public taskCount = 0;
}

 struct Task {
    uint id;
    string content;
    bool completed;
}

mapping(uint => Task) public tasks;

event TaskCreated(uint id,string content,bool completed);
event TaskToggled(uint id,bool completed);

construct() public {
    createTask("Default Todo Task");
}

function createTask(string memory _content) public{
    taskCount ++;
    tasks[taskCount]=Task(taskCount, _content, false);
    emit TaskCreated(taskCount, _content, false);
}

function toggleTask(uint _id) public {
    Task memory _task = tasks[_id];
    _task.completed = !_task.completed;
    tasks[_id] = _task;
    emit TaskToggled(_id, _task.completed);
}


texts: How to get specific event log in contract?

texts:
I can obtain all event logs.
My code is:

var contractInstance = contract.at("0x123456...789");
var transferEvents = contractInstance.allEvents({fromBlock:0, toBlock:'latest'});

and the output is:

{ address: '0xafe6851c1d9ee2e759acdee8cfc827e22a9ec5d7',
blockHash: '0xe5cdc4ae1e70ad4b4610a1f5a45fb3ff56bc3530f159ab0613ffeb33a7bf9c0a',
blockNumber: 1924935,
logIndex: 3,
transactionHash: '0x2e18ac5cb925b95ec609970e66d566623f446bc67bd0b72aac0a2ca6e96ef128',
transactionIndex: 4,
event: 'Transfer',
args:
 { from: '0xd94c9ff168dc6aebf9b6cc86deff54f3fb0afc33',
   to: '0x414755edffa43707f7d51600edf9ecbe57152a8a',
   value: [Object] } },

But i obtain get Transfer event data

var contractInstance = contract.at("0x123456...789");
var transferEvents = contractInstance.Transfer({fromBlock:0, toBlock:'latest'});

the output is empty.

Is there any problem in my code?


texts:
I am new to blockchain and ethereum. I created a private network with two nodes, I have couple of questions:

After starting the miner it starts mining even if there is no transaction performed. So what is the miner mining and what is the significance of it?
When I transfer some ether to another using the mist wallet it says it is pending 12 approvals, how we reach to this figure of 12 approvals, is it configurable.?

TIA


texts:
I copied a smart contract and deployed it from my account on Mist on Rinkeby Network.

All functions are working as expected except one. I will post the code here :

event PerformingDrop(uint count);
function drop(address[] addresses, uint256 amount) public onlyOwner {
  uint256 amt = amount * 10**8;
  require(amt > 0);
  require(amt <= SUPPLY_CAP);
  PerformingDrop(addresses.length);

  // Maximum drop is 1000 addresses
  assert(addresses.length <= 1000);
  assert(balances[owner] >= amt * addresses.length);
  for (uint i = 0; i < addresses.length; i++) {
    address recipient = addresses[i];
    if(recipient != NULL_ADDRESS) {
      balances[owner] -= amt;
      balances[recipient] += amt;
      Transfer(owner, recipient, amt);
     }
   }
 }

I am executing this contract from my main account which has 2.97 ether available.

No of Tokens: 10000000.00000000
Decimals : 8

I am passing array of addresses as 1st param e.g [‘Address1’, ‘ Address2’] and number of tokens to drop.

Whenever I perform a drop of 10000000 drop works fine but if I increase even 1 more digit let say 100000000 then the error shown in image occurs.

What could be the issue?


texts:
I have been using Infura site for accessing main Ethereum network, but newly this site has changed its services and don't service send methods.

I searched a little and found Quicknode site, but unfortunately it is nor free of charge. I also found Alchemy site, but it cannot send email for registration, how can I trust it to operate properly.

So I ask you to introduce a replacement for Infura site that response to JSON RPC calls.


texts: Running A Smart Contract With Two Nodes on Truffle

texts:
We have installed truffle to two nodes and we initialize our private blockchain with:
$geth --datadir node init genesis.json

Then we run geth on both nodes with:
$geth --datadir node --nodiscover -rpc --rpcapi="db,eth,net,web3,personal,web3"  console

We are using same genesis.json files.

After that, we migrate contract on both nodes, and we are using:

  ContractName.deployed()
  var contract = ContractName.at('address')

Then in the two nodes we run function like that:

  contract.then(function(cI){cI.addValue().then(function(v){console.log(v)})})

However, after a node run the contract, other node don't run on the same contract, I mean, if we want to show the values added to an array, every node shows it's own array, not a single one.

Are we running contracts in two nodes in a wrong way?

Edit: Solved the problem. We have migrated smart contract on a single node, then in all nodes, we simply created a contract instance with

  var contract = ContractName.at('address')


texts: Which ethereum dapps are 100% decentralized and not semi-decentralized (centralized)?

texts:
Correct me if I'm wrong here, but I see dapps as independent solo code that you can download to you computer and it interacts with the Ethereum blockchain.

Looking at crypto kitties, you have to access this from their website and the kitty images are stored on their website. How is that considered a dapp? It looks more like just an app.

Same goes for etherdelta, you have to goto the website to use it, but you can't download it and run it locally to modify it to make trades.

Am I correct in seeing these as semi-decentralized (centralized) apps?

Are there dapps that are truly 100% independent that doesnt rely on a central server to fetch data such as images or data?


texts: Is it safe to share Smart Contract code from GitHub with developer?

texts:
Hi

We have finished our smart contract development and are looking at candidates for a security audit

Is it safe to share our GitHub repo with a smart contract developer in order for him to give pricing and timeframe for a security audit?


texts: How to get overall transaction count of the entire network

texts:
I'm running small etherium network on two parity clusters which have no internet connection so etherscan is a no-way.

I wonder if it's possible to get overall transaction count via JSON RPC or something. I need to get something like eth_transactionCount and get 100500 as result.

How can it be done if it's possible at all?


texts:
I have a simple contract to set and get a uint256 variable:

contract testContract {

   uint256 test;

   function testContract() {
   }

   function getTest() constant returns (uint256) {
       return test;
   }

   function setTest(uint256 _test) {
       test = _test;
   }
}

On geth, I update the test variable by

myContract.setTest.sendTransaction(0x12345678901234567890,{from: web3.eth.accounts[0]});

Now to read the variable by

var cardPK = myContract.getTest.call();
console.log("test: " + cardPK.toString(16));

And I obtained

test: 12345678901233c56f80

Why is it wrong?


texts:
We're having issues with remix. It crashes on third iteration in for loop. When we try to run verify method, it successfully runs 2 iterations of for loop. However, in third iteration remix crashes. Here is part of our code:
function verifyFairness (string memory clientSeed, string memory privateKey, uint minRange, uint maxRange, uint256[] memory results) public pure returns (bool) {
    string memory newPrivateKey = "";
    for(uint i=0; i<results.length; i++){
        if(i == 0) {
            newPrivateKey = privateKey;
        }
        if (results[i] == calculateNumber (clientSeed, newPrivateKey, minRange, maxRange)){
            newPrivateKey = string(abi.encodePacked(calculateServerSecretHash(results[i], newPrivateKey)));
        } else {
            return false;
        }
    }
    return true;
}

CalculateNumber and CalculateServerHash are our methods. In one we use keccak256 and in other is one for loop.


texts:
I am writing a Medium blog post about front-running and can't seem to find information about the order of the transactions in the same block. I have executed two trades, one with the lower fee, call it A: https://etherscan.io/tx/0x7332ec032bcd421e8137a623c542f38448bd7860b4b310acf4aef940dae85778, and one with the higher gasPrice and the same amount of gas, B: https://etherscan.io/tx/0x422d289768ce4fd6a7acf15dad9326ac80aaf0dcda696c306da69d5e83bfeb9b. They were both included in the same block: https://etherscan.io/block/9494989. Which transaction occurred first, A or B?

And in general, how does one retrieve the order of transactions in the same block?


texts: Event.watch gets fired infinitely many times

texts:
I am trying out truffle + web3 + ethereumjs-testrpc. In the app I have the following code:

window.onload = function() {
  var meta = MetaCoin.deployed();
  var event = meta.Transfer({}, {fromBlock: 0, toBlock: 'latest'}, function (error, result) {
    if (error) {
      console.log("Error: " + error);
    } else {
      console.log(result);
    }
  });
}

and I am getting the latest transfer endlessly in console.
The contract is standard MetaCoin with an event Transfer added. Here is the full code.


texts: What is the difference between transaction and message?

texts:
What is the definition of a transaction and a message in Ethereum?
How are they different?


texts: How much could it cost to implement blockchain through ethereum partners?

texts:
I would like to have more details regarding the pricing model for implementing Ethereum service through Azure, or in Monax?

I just need an estimation or a range (between x and y). It's for educational purposes.

Thank you in advance!


texts: Can block validation be done using machine Learning Algorithms?

texts:
I am looking for a new era of products that leverages the potential of Machine Learning and the blockchain, Thinking of different aspects of Blockchain which can be improved with the help of machine learning.

Can we validate the block's transactions using ML Algos / Come to a consensus using ML?

Exploration appreciated!


texts: nodejs 3.10.9, installation web3, ReferenceError: web3 is not defined

texts:
I'm running:

nodejs 3.10.9
geth 1.4.18-stable-c72f5459

I did the folowing steps:

run geth --testnet --rpc
installed web3 via npm install web3 -g.
run node (console)
when I am in the node-console and run: console.log(web3);

I get the error:

ReferenceError: web3 is not defined
at repl:1:1
at REPLServer.defaultEval (repl.js:262:27)
at bound (domain.js:287:14)
at REPLServer.runBound [as eval] (domain.js:300:12)
at REPLServer.<anonymous> (repl.js:431:12)
at emitOne (events.js:82:20)
at REPLServer.emit (events.js:169:7)
at REPLServer.Interface._onLine (readline.js:211:10)
at REPLServer.Interface._line (readline.js:550:8)
at REPLServer.Interface._ttyWrite (readline.js:827:14)

When I run require('web3') in node console I get the same error.

I also tried to install web3 without -g (npm install web3); same result.

What am I doing wrong?
Why is web3 not recognized by node after the installation through npm install web3 -g?

I tried to do the installation according to this thread:
How to connect NodeJS to the Ethereum network?

and the documentation:
https://www.npmjs.com/package/web3


texts: How to convert getBalance output to ether in web3 1.0

texts:
I tried web3.js 1.0.0-beta.

I found in document method web3.utils.fromWei(value, 'ether') convert the wei to ether. In new version getBalance method work as asynchronous. how can I get the value from getBlance then passed as Big number

I tried

web3.utils.fromWei(
 web3.eth.getBalance("0x90f8bf6a479f320ead074411a4b0e7944ea8c9c1"),'ether');

But got error!


texts:
How can I check an address to see what custom tokens has been generated at it?

This is a testnet (Ropsten) address for example:

0xc8f836f4236e3e58f5417589b2d677abd7558cd5

I know that on Ropsten it has a custom token.

I am using Geth and I want to know what I should input to get a list of the tokens created at the address above and the name of the token.

Vesa


texts: Quorum cakeshop - Error while starting up

texts:
I hava a question regarding Quorum cakeshop.

Currently I am trying to get the cakeshop running, what i want to use to play a around with Quorum a little. More infos below:
https://github.com/jpmorganchase/cakeshop/blob/master/README.md

I followed the Quickstart instructions via Spring Boot but I am running in an error (OS=Windows10).

The manual tells me to run this command "java -jar cakeshop.war".
While doing this I get a bunch of Errors from the filemanager coming from a java FileNotFoundException. Anyone has the same kind of problem or any ideas of how to solve this problem?

Also does anybody know if there is a place where I can ask specific Quorum questions?

Many thanks!


texts: How much gas does an ERC20 transfer cost?

texts:
ERC20 is an interface and not a contract definition. And since gas is paid for each executed machine instruction, it is not possible to specify precisely how much a call to transfer costs for an ERC20 contract. This will depend on how the ERC20 contract is implemented (in Solidity) and how it is compiled to EVM code.

However: is it possible to say something general about this gas costs or does there exists a reference implementation where we can precisely say how much such a method call costs? And does there exist a lower limit for this number?

By looking a ERC20 transfer calls on etherscan.io, it seems that the gas cost is between 50.000 and 105.000.

I have set the gas limit to 200.000 on a wallet that I have built. So far, I have not encountered an ERC20 transfer call that has exceeded this limit.


texts: Account "lost" after using --datadir in Geth

texts:
I am extremely new to Ethereum, just started mining a bit 2 days ago. I use Windows 10 and a GeForce GTX 950 card.
I have had geth running smoothly for about 2 days, then it started filling up my AppData in my C drive, leaving only 4 GB of space left.

Out of desperation, I did something very stupid by trying to copy the entire AppData folder to my other drive and then I used geth --datadir to try to direct the huge amounts of file storage go into my other drive. When I tried to run Geth, it didn't work, so I used --datadir again to swap it back to my C drive and deleted my entire copied AppData folder on my other drive.

When I did geth --rpc again, it said no etherbase set and no accounts found as default

and when I do the ethminer.exe -G on another window, errors pop saying I have no set etherbase.

I have been mining for 2 days and I know it's not too much, but yesterday when I checked I had a bit of ether by using eth.getBalance and I know all my keys and passwords and addresses and stuff are all here somewhere, but I just don't know where and how to use etherbase and re-set it up.

I tried to log in again using personal.unlockAccount(eth.accounts[0], "password") but it cannot find my account. I don't even know where and how geth stores a local account.

I have my local account address on a sticky note it looks like
af104bda8 etc etc
(I don't think that's a key)
and I remember my passphrase, my keystore folder had a file in it but after I tried copying AppData to another drive the file inside disappeared.

I'm very lost what do I do?


texts: How does uniswap process so many transactions on the clogged ethereum network?

texts:
According to info.uniswap.org, the number of uniswap transactions in the last 24 hours was 136,383.
This amounts to approximately 136383 / 24 / 60 / 4 = 24 transactions per block.
It appears that with basic ether transactions, you'd be able to approximately triple that volume in a single block.
How does uniswap process that many transactions on ethereum when there is so much competition to get transactions included in the blockchain?
Is uniswap actually accounting for about 33% of all transactions? (And if the gas used for uniswap transactions is more than that of regular ether transactions, wouldn't this be actually higher than 33%?)
Or does uniswap use some other mechanism to allow more transactions to take place without hogging the ethereum network?


texts: Event firing before data is actually set [Testnet]

texts:
Today I've faced the behavior similiar to this post.
Event firing before data is actually set

I'm getting events using infura and then checking for the state. I expect to read updated blockchain state according to the fired event. But I always get the old state.

In the post above changing to public testnet solved the problem.
I've tried Ropsten, Kovan and Rinkeby testnets. The same behavior everywhere.

What happened? Is blockchain broken?


texts: I am totally new to the Solidity Programing. I was working on NodeJS, express and mongoDB. Few days ago I started working on blockchain. I have to write the API'S for contracts. We are using truffle and tronweb. Is there any simple project or tutorial available which gives me idea of how this whole thing works.


texts: Probably scammed by a coin which doesn't allow to sell, only to buy

texts:
As the title says - the coin: https://etherscan.io/token/0x6d85dd21d470e5c1e6af3a5198f0d5ac4dcdd7ef
It only allows you to buy, but not to sell - I might still have a chance to recover my ETH, since I saw this post:
Their are several ways to do that. First be the simplest one, It disabled approve function in the erc20 token contract. That means uniswap cant get your approval for putting the coin to be sold. After this, some of them has a rebase function. When you transfer the tokens to a smart contract address, you will loss 99.99999 percent of it. I found only an answer to the first problem, by use transfer function, instead transfer from. To the second problem, I have no answer yet. Just be careful of the tokens that have no source code published. The most dangerous one being the tokens, that had only buying actions. and all the sold actions come from a same address. Those scammers dont even change their address when they deploy new contract. they made 400eth from 80eth. After a few days they just simply empty the liquidity.
I used the Fortmatic wallet with the Zerion App.

Thank you for the useless answer - I am asking for help actually, using these commands.
Please read next time :)


texts: How to generate private, public and ethereum addresses using web3.py?

texts:
I want to know the process of generating the keys for ethereum using web3.py. How to generate the keys if I install my ether node.

from web3 import Web3, HTTPProvider, IPCProvider
web3 = Web3(HTTPProvider('http://localhost:8545'))

I configured the node. Now, what is the method to get the keys (private, public and ether address)? Please explain.


texts: How did "The DAO" come about?  What was the process of its formation?  Who "made" it happen?


texts: simulate transaction without sending to blockchain

texts: Is there any way to simulate a transaction without sending it to the blockchain and find the exact error (or line of code), in case it fails if its mined?


texts: What should be the input for following functions in web3js?

texts:
web3 js functions like:

getTransaction() What should be the input? contract address or account address or transaction hash?

likewise for other contracts like getTransactionReceipt and all?


texts: Access private transactions(payload or state) on a smart contract using tessera

texts:
I am pretty new to quorum/tessera and am trying to set up a small POC with 3 nodes. I followed the 7nodes setup example and similarly deployed 3 nodes on my system using Mysql as the database for tessera. What I want to do is:
Deploy a smart contract(privately) for the 3 nodes and do a private transaction between 2 nodes only (which change a state variable). Now, I understand that quorum maintains a public as well as a private state trie. How can I access the change created by the private transaction between these 2 nodes?
My smart contract is:
pragma solidity >=0.4.22 <0.7.0;

contract SampleContract {

    uint256 num1;
    uint256 num2;

    function store1(uint256 number) public {
        num1 = number;
    }

    function store2(uint256 number) public {
        num2 = number;
    }

    function getVal1() public view returns(uint256){
        return num1;
    }

    function getVal2() public view returns (uint256){
        return num2;
    }
}

DeploySampleContract.js
var abi = [abi-here];
var bytecode = "bytecode-here";
var simpleContract = web3.eth.contract(abi);
var simple = simpleContract.new({from:web3.eth.accounts[0], data: bytecode, gas: '4700000', privateFor: ["pub-key-of-node2","pub-key-of-node3"]}, function(e, contract) {
    if (e) {
        console.log("err creating contract", e);
    } else {
        if (!contract.address) {
            console.log("Contract transaction send: TransactionHash: " + contract.transactionHash + " waiting to be mined...");
        } else {
            console.log("Contract mined! Address: " + contract.address);
            console.log(contract);
        }
    }
});

I use the following command to deploy:
geth --exec 'loadScript("DeploySampleContract.js")' attach http://localhost:22000

My query/send file:
var abi = [abi-here];
var private = eth.contract(abi).at("contract-address-here");
// console.log(private.store1.sendTransaction(27,{from: eth.coinbase}));
// console.log(private.store1.sendTransaction(28,{from: eth.coinbase, privateFor: ["pub-key-node2"]}));
console.log(private.getVal1.call());

I have run the above for both types of sendTransaction (and the transaction is successful, commented them out afterwards) but the value of num1 returned by getVal1() is still 0. What is the method to access both the transactions' data/state?
Thanks.


texts:
I have seen Ethereum Studio from ether.camp recommended in various places, but to download it requires some registration, so I assume it is not open source, although it claims to be based on cloud9. Some people might object against using closed source product for applications that may deal with large sums.

Is it really closed-source? What makes people use it? And being "cloud", does it require constant internet access, and does it save source files in the cloud?


texts: In the Mix IDE how do I view tokens belonging to a user

texts: In the Mix IDE is it possible to view the tokens a user currently has in their account for debugging purposes.


texts: Couldn't connect to node because cross-origin request is blocked

texts:
I am running a full rinkeby node via

geth --rinkeby --rpc --rpcapi db,eth,net,web3,personal --cache=2048  --unlock="..." --password ... --rpccorsdomain "*" --allow-insecure-unlock --rpcaddr "localhost"

The node is up and I could deploy a smart contract via truffle migrate --rinkeby and the config

rinkeby: {
      host: "localhost", // Connect to geth on the specified
      port: 8545,
      from: "...", // default address to use for any transaction Truffle makes during migrations
      network_id: 4,
      gas: 4612388 // Gas limit used for deploys
    }

My DApp is supposed to connect to the blockchain:

var web3Provider = new Web3.providers.HttpProvider('http://localhost:8545');
var web3 = new Web3(web3Provider);
var startBlock = web3.eth.blockNumber;

I get the following error (Firefox, similar for Chromium):

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost:8545/. (Reason: CORS request did not succeed)
Error: CONNECTION ERROR: Couldn't connect to node http://localhost:8545.

My DApp runs on an nginx webserver (nginx/1.14.0 (Ubuntu)).

My geth version is 1.8.27.

Any ideas on what else I could try?


texts: "Revert: VM Exception while processing transaction" while trying to swap with 1Inch

texts:
since a while I am trying to program a swap contract for 1Inch. The problem is that I always get a Revert message when trying to call the function.
I made sure that the contract has enough funds from the token I want to swap. I imported all Interfaces properly and already deployed the contract on my testnet.
Here is the code which I've written:
    function OneInch(uint amount, address fromtoken, address totoken) public returns (uint){
        IERC20 srcToken = IERC20(fromtoken);
        IERC20 dstToken = IERC20(totoken);

        IOneSplit onesplit = IOneSplit(ONEINCH_ROUTER_ADDRESS);
        srcToken.approve(address(onesplit), amount);
        (uint rate, uint[] memory distribution) = onesplit.getExpectedReturn(srcToken, dstToken, amount, 100, 0);
        uint minimumReturn = rate * 99 / 100;
        uint returnedAmount = onesplit.swap(
            srcToken,
            dstToken,
            rate,
            minimumReturn,
            distribution,
            0);

        return returnedAmount;
    }

Here are the docs for 1Inch: https://github.com/1inch-exchange/1inchProtocol


texts:
Victim contract allows one time withdraw only. I want to attack it using stack depth attack to withdraw everything it has. I've tried different things, but can't get the desired result. Here's where I'm stuck:

My actions:

Attacker.setVictimAddress(victimAddress);
Attacker.reachStackDepth(0);

contract Attacker {
    address victimAddress;
    function attack(){
        victimAddress.call.value(1 ether)(bytes4(sha3('bid()')), this);
    }
    function reachStackDepth(uint x){
        if(x == 1023) {
            attack();
        }
        Attacker(this).reachStackDepth(x++);
    }
    function setVictimAddress(address _victimAddress){
        victimAddress = _victimAddress;
    }
}

contract Victim {
   address highestBidder;
   uint highestBid;
   function bid() {
      if (msg.value < highestBid) throw;
      if (highestBidder != 0)
      highestBidder.send(highestBid); // refund previous bidder
      highestBidder = msg.sender;
      highestBid = msg.value;
   }
}

Here's VM trace and all that https://testnet.etherscan.io/vmtrace?txhash=0x285acada3e003173d6e90855ebb44872b3065037b323d5858f6c12c160a98eb5


texts: Why do I see some random transactions to "The DAO" in my mist client?

texts:
I am curious to know, why I do see some random transactions of "The DAO" in my mist client within my "last transactions" section. I have actually two of them yet:

Is it because I watch my Tokens?


texts: How to transfer any ERC20 token in Solidity from my smart contract?

texts:
I am having trouble with transfering ERC20 tokens in my smart contract. Code is below. Take a look at function hodl, I want to deposit any token to this smart contract, but although I make a transaction no tokens are transfered, I am not sure why because I do call transferFrom function. Tried with transfer as well in desperation but that's probably only for token smart contract transfers.

What I am trying to develop here is a smart contract that will accept a token deposit and hold it until a time limit defined by the user when making a transaction expires.

pragma solidity ^0.4.19;

contract ERC20Interface {
function totalSupply() public constant returns (uint);

function balanceOf(address tokenOwner) public constant returns (uint balance);

function allowance(address tokenOwner, address spender) public constant returns (uint remaining);

function transfer(address to, uint tokens) public returns (bool success);

function approve(address spender, uint tokens) public returns (bool success);

function transferFrom(address from, address to, uint tokens) public returns (bool success);

event Transfer(address indexed from, address indexed to, uint tokens);
event Approval(address indexed tokenOwner, address indexed spender, uint tokens);
}

contract hodlForYouContractV3 {

event Hodl(address indexed hodler, address token, uint  amount, uint timeLimit);

event PanicSell(address indexed hodler, address token, uint  amount, uint timediff);

event Withdrawal(address indexed hodler, address token, uint  amount);

struct Hodler {
    uint etherBalance;
    address hodler;
    mapping(address => Token) tokens;
}

struct Token {
    bytes32 symbol;
    uint tokenBalance;
    address tokenAddress;
    uint timeLimit;
}

mapping(address => Hodler) public hodlers;

function hodl(address token, byte tokenSymbol, uint256 amount, uint256 timeLimit) {

    hodlers[msg.sender] = Hodler(0, msg.sender);
    Hodler hodler = hodlers[msg.sender];
    hodler.tokens[token] = Token(tokenSymbol, amount, token, timeLimit);
    //        hodler.tokens[token].timeLimit = timeLimit;
    //        hodler.tokens[token].tokenBalance = amount;
    ERC20Interface(token).approve(msg.sender, amount);
    ERC20Interface(token).transfer(this, amount);
    ERC20Interface(token).transferFrom(msg.sender, this, amount);
    Hodl(msg.sender, token, amount, timeLimit);

}

function withdraw(address token) {
    Hodler hodler = hodlers[msg.sender];
    require(block.timestamp > hodler.tokens[token].timeLimit);

    uint amount = hodler.tokens[token].tokenBalance;
    hodler.tokens[token].tokenBalance = 0;
    ERC20Interface(token).approve(msg.sender, amount);
    ERC20Interface(token).transferFrom(this, msg.sender, amount);

    Withdrawal(msg.sender, token, amount);

}

function panicSell(address token) {
    //This function should have a fee for quicker withdrawing without waiting
    Hodler hodler = hodlers[msg.sender];

    uint amount = hodler.tokens[token].tokenBalance;
    hodler.tokens[token].tokenBalance = 0;
    ERC20Interface(token).approve(msg.sender, amount);
    ERC20Interface(token).transferFrom(this, msg.sender, amount);

    PanicSell(msg.sender, token, amount, hodler.tokens[token].timeLimit - block.timestamp);

}

}


texts: web3j.ethSendRawTransaction wait until the transaction is successfully mined - Web3j

texts:
Im trying to send 0 ether to the same account with Web3j, however when i run this code it give me directly the transaction hash, even if the transaction has not been mined yet and still pending. I can't use the method Transfer.sendFund(..) because i need the nonce to be given by me.

RawTransaction rawTransaction = RawTransaction.createEtherTransaction(nonce,
    gasPriceInWei, gasLimit, credentials.getAddress(), BigInteger.ZERO);

byte[] signedMessage = TransactionEncoder.signMessage(rawTransaction,
    credentials);

String hexValue = Numeric.toHexString(signedMessage);

EthSendTransaction ethSendTransaction =
    web3j.ethSendRawTransaction(hexValue).sendAsync().get();

String transactionHash = ethSendTransaction.getTransactionHash();

System.out.println("transaction hash: " , transactionHash )

Does anyone have an idea to solve this probelm?

("web3j.ethSendRawTransaction(hexValue).send()" dont solve this)

(watch all new transactions in each new blocks until my transaction occure is a solution, but is there a better way)?


texts:
I know a little about Ethereum and how it works, but what am I wondering is that why we exactly need a transaction to be stored in Ethereum blockchain? What's confusing for me is that Ethereum client like Go using leveldb for keeping data like account storage in every node locally. Moreover if a user want to read/write the value of the variable/function of the contract, he send a transaction to change the state and it is broadcast to the network and a miner run this transaction in his VM and the VM get data from the account storage that store in the LevelDB and then change the value and whatsoever. Am I right till now?
If I am right, for reading and writing we keep looking for LevelDB  not the transactions that stored in the Ethereum. In contrast in Bitcoin for knowing how much is the balance of somebody we check the last transaction to this account and see its UTXOs, but that is not happening in Ethereum. Because we just set the transaction to change the leveldb and nothing more happens (if I am not wrong).
We keep changing the state and write transactions for that and the transaction store forever in blockchain.
So why do we exactly need chains of block for keep recording of transactions since all the data is in the separate database?
Do we check transactions in the Ethereum? And if the response is yes, for what do we look for transactions and keeping them?
so what happened exactly when a user read/write data from Ethereum?
Is it refer to Transaction that stored in Ethereum or refer to a leveldb? and if it refer to a leveldb so what is the need for chain of block?
That would be great if somebody help me from this confusion!


texts: is there a website like coinbase i can buy ether at?

texts: I would like to buy ether but i don't know of any legitimate websites like Coinbase for trading ether. I would like to buy ether with dollars. Does anyone know of a website i can go to, to buy ether with US dollars?


texts: Contract state won't change during Truffle tests

texts:
I am trying to test my contracts using the Truffle suite, along with Ganache.

Up until now, I have been testing contract functions which are restricted to view only.  Now, when I attempt to make changes to the contract state, I'm finding that the state is not actually being changed between function calls.

Consider the following simple contract:

pragma solidity ^0.4.24;

import "../OrderBook.sol";

contract IdManager {
    uint256 newId;

    function addId() public returns (uint256) {
        newId++;
        return newId;
    }
}

All I wish to do is increment newId and return its new value.

The code I have written to test this is:

const { getWeb3, getContractInstance, parseSignature } = require("./test_helper");
const web3 = getWeb3();
const getInstance = getContractInstance(web3);

contract('IdManager', (accounts) => {
    let IdManager = getInstance('IdManager');

    it('test addId()', async () => {
        console.log(await IdManager.methods.addId().call());
        console.log(await IdManager.methods.addId().call());
        console.log(await IdManager.methods.addId().call());
    });
});

The getInstance() call is making use of Web3 v1.0, based off this tutorial.

With the above test, I would expect the output to be:

1
2
3

But, I actually get:

1
1
1

Has anyone come across this issue before?

Edit0:

console.log(await IdManager.methods.newId().call()); should have been console.log(await IdManager.methods.addId().call());—newId() is now addId().

Edit1:

Taking goodvibration's advice, I have modified the example contract to be as follows:

contract IdManager {
    uint256 public newId;

    function addId() public {
        newId++;
    }

    function getId() public view returns (uint256) {
        return newId;
    }
}

The test code has been altered to the following:

it('test addId()', async () => {
    await IdManager.methods.addId().call();
    console.log(await IdManager.methods.getId().call());

    await IdManager.methods.addId().call();
    console.log(await IdManager.methods.getId().call());

    await IdManager.methods.addId().call();
    console.log(await IdManager.methods.getId().call());
});

Unfortunately, my output is still showing that the state is not being preserved:

0
0
0


texts: Smart Contract Transfer Event Log Data & transfer _value [Rust]

texts:
I'd like to have a better understanding of events and logs data, more specifically when it comes to interacting with ERC20 tokens smart contracts and their Transfer events.

I'm looking for a way to extract the transfer value/amount from the returned (transaction) Log struct as described in the rust-web3 documentation.

I understand that from the event log, the topics field has 3 values:

topics[0] is the keccak-256 of the
Transfer(address,address,uint256) canonical signature.
topics[1] is the value of the _from address.
topics[2] is the value of the _to address.

However, I cannot seem to find the ERC20 token transaction value in the returned Log struct or the log or input field as described in this thread and this one.

I suspect I can extract the transfer amount in an ERC20 token transaction from the data field in the events log but I haven’t figured how to do that yet. data is of type Bytes, i.e. a Vec<u8>, a vector of 32 u8.

Thanks.


texts:
Hello i want to create website wallet bsc and erc based tokens where person can withdraw and deposit tokens on his account wallet.
How do i make it is there any complete guide?


texts: What happens to a transaction after you clicked 'send' in Ethereum network?[Transaction life cycle at the EVM and P2P networking level]?

texts:
Ref:  What happens when you type in an URL in the browser

So in a web browser, it's kinda easy to reason the life cycle of an HTTP request, how it moves down the network stack, reach the server, get a response and travel back up to my browser and gets rendered as a web page.

var contractAbi = eth.contract(AbiOfContract);
var myContract = contractAbi.at(contractAddress);
// suppose you want to call a function named myFunction of myContract
var getData = myContract.myFunction.getData(function parameters);
//finally paas this data parameter to send Transaction
web3.eth.sendTransaction({to:Contractaddress, from:Accountaddress, data: getData});

What happens when I type the following code in a geth console of a 2 node private Ethereum network(1 full pair node, 1 mining node)? Let's say we are running a light client.

The raw request(JSON RPC) would be sent to 1 of the 2 nodes or broadcast to both of the 2 node at the same time?
How is the p2p module involved in the whole picture? Just maintain the alist of nodes in the entire 2-node network or just a subset?
What happens when the raws request reach the first Ethereum node or second? Does it differ (first or sencond)?
How is EVM work in the picture if I treat it as an blackbox? How the interface look like(input, output)?

EDIT 1: Let's assumming we are using POW. But since there is only one single mining node, POA is fine as well?

EDIT 2: In terms of performing the computation of the transaction(eg. 1+1), how do the mining node(say POA) and normal peer full node differ if they do differ?

EDIT 3: This articledid a great job at explaining on a higher level how a transaction get validated by all the nodes and only get "run" by the mining node, and after being included into the mining node, how a block get broadcasted and its transactions get further validated and propagated until the sender pickup the EVM logs. But how exactly EVM "crunch" the transactions and mutate the state? and how the p2p modules maintain all the nodes?

EDIT 4: this is another nice short read summarizing it as : construct->sign->broadcast->mine

found this cool image here


texts: Declaring a memory array of storage pointers in Solidity

texts:
I would like to declare a variable as a memory array of pointers to storage arrays of uint256.

For example:

pragma solidity ^0.4.24;

contract A
{
    uint256[] public array0;
    uint256[] public array1;
    constructor () public
    {
        array0.push(123);
        array1.push(456);
    }
    function test() public
    {
        uint256[][] memory storageArrays = new uint256[][](2);
        storageArrays[0] = array0;
        storageArrays[1] = array1;

        storageArrays[0][0]++;
        storageArrays[1][0]--;
    }
}

I want this to change the values of array0 and array1, but they don't change because the storage arrays were implicitly copied to memory. This code only changes their copy in memory.

This is because both dimensions of the array are set to memory. I would like the first dimension of the array to be storage, and the second one memory

I tried to declare storageArrays like this:

uint256[] storage [] memory storageArrays = new uint256[][](2);

But it gives this syntax error:

ParserError: Expected identifier but got '['
uint256[] storage [] memory storageArrays = new uint256[][](2);
                  ^

Is it possible? If so, how? Thanks in advance.


texts:
QUESTION:

Is it worth it to have events in your token? Each transaction usually has the event inside it meaning more gas is spent for the users (which is bad). I don't have a full picture of all the good events bring to the picture so it's hard for me to decide whether to include them in tokens I code.

ELABORATING:

After a lot of digging, I came to understand that events (such as those in the ERC-20 token standard) are just logs that provide an easier way for Apps to check what is happening with your token, but don't provide any functionality in terms of making the token work. For instance, here is a subset of code from the ERC-20 Token Standard:

function transfer(address _to, uint _value) returns (bool success);
event Transfer(address indexed _from, address indexed _to, uint _value);

First line is the declaration of the transfer function, while the second is the declaration of the Transfer event. In terms of transactions, the ERC-20 token does just fine without a Transfer event. So why should events even be included if they add gas costs to each transaction? I don't know what the good sides are of having events, and if they outweigh the bad sides, which is why I pose this question.


texts: How Can You Map a Struct Twice With Different Keys?

texts:
I have a struct mapped with an address as the key. I want to iterate through all values of that mapping with another key value, in this case a nonce that I generate in the contract. Is this possible? What is the correct terminology for this process if it is?

I have been pouring over all of Rob Hitchens' storage posts (Are there well-solved and simple storage patterns for Solidity? among others), but I'm stuck conceptually. I know I can just create an array, but since I want to be able to delete records by address, a mapping makes much more sense. I also know I can create a mapping and a second array to track all of the addresses, but that is much more wasteful than having a single mapping.

Here is current code and context:

struct Subscription {
    address subscriberAddress; //Address of the subscriber.
    uint256 timeOfLastCharge; //Time in Unix seconds.
    uint256 nonce;
}

mapping(address => Subscriptions) public subscriptionRegistry; // List of all subscribers. Lookup via subscriber address.

//mapping(address => uint)

function initiateSubscription (address _subscriberAddress) external {

    require(msg.sender == contractManager, "You are not authorized to call this function.");
    require(subscriptionRegistry[_subscriberAddress].subscriberAddress == address(0), "A subscription already exists for this address.");

    Subscription storage newSubscription = Subscriptions[_subscriberAddress];
    newSubscription.subscriberAddress = _subscriberAddress;
    newSubscription.timeOfLastCharge = now;
    newSubscription.nonce = currentNonce;

    tokenContract.transferFrom(_subscriberAddress, merchant, subscriptionPrice);

    emit subscriptionEvent(_subscriberAddress, subscriptionPrice, billingInterval);
}


texts: eth.Ethereum config to mimic geth command line defaults

texts:
I'm trying to start a full ethereum node in go using my existing chaindb, but can't get the configuration right and was hoping someone could point me in the right direction.

Attempted something similar to what is described here (In-process Full Node section: https://twurst.com/articles/geth-1.5-api.html). However, the code below only returns the genesis block (and fails if I try any other block), so I assume something is wrong with my setup.

func main() {
    stackConf := &node.Config{
        DataDir: "/Users/me/Library/Ethereum",
    }
    ethConf := &eth.DefaultConfig

    stack, err := node.New(stackConf)
    if err != nil {
        log.Fatalf("protocol stack: %v", err)
    }
    if err = stack.Register(func(ctx *node.ServiceContext) (node.Service, error) { return eth.New(ctx, ethConf) }); err != nil {
        log.Fatalf("failed to register Ethereum protocol: %v", err)
    }
    if err = stack.Start(); err != nil {
        log.Fatalf("failed to start test stack: %v", err)
    }
    var ethereum *eth.Ethereum
    stack.Service(&ethereum)
    stack.Start()
    latestBlock, err := ethereum.ApiBackend.BlockByNumber(context.Background(), -1)
    if err != nil {
        log.Fatal(err)
    }
    log.Println(latestBlock)
    log.Println("latest block:", latestBlock.Number())
}

I'm not using the RPC, since the method I'm interested in using is GetReceipts, which gets all of the receipts for a given block, whereas the RPC only allows for grabbing the receipt for a single transaction (i.e. have to call for every transaction in the block).


texts: How to transfer a contract address to ContractRef type(ContractRef is a reference to the contract's backing object) in Go-ethereum

texts:
I want to call DelegateCall(caller ContractRef, addr common.Address, input []byte, gas uint64) in geth, but it can only be triggered by the opcode.  So I want to convert address of deployed contract to ContractRef type, as the first parameter of Delegatcall, but i don't know how to realize it.　Since caller should be the address of contract object, and common.Address(caller) shouldn't be nil.
Or is there any other way to realize it?
// ContractRef is a reference to the contract's backing object
type ContractRef interface {
    Address() common.Address
}

// AccountRef implements ContractRef.
//
// Account references are used during EVM initialisation and
// it's primary use is to fetch addresses. Removing this object
// proves difficult because of the cached jump destinations which
// are fetched from the parent contract (i.e. the caller), which
// is a ContractRef.
type AccountRef common.Address

// Address casts AccountRef to a Address
func (ar AccountRef) Address() common.Address { return (common.Address)(ar) }

// Contract represents an ethereum contract in the state database. It contains
// the contract code, calling arguments. Contract implements ContractRef
type Contract struct {
    // CallerAddress is the result of the caller which initialised this
    // contract. However when the "call method" is delegated this value
    // needs to be initialised to that of the caller's caller.
    CallerAddress common.Address
    caller        ContractRef
    self          ContractRef

    jumpdests map[common.Hash]bitvec // Aggregated result of JUMPDEST analysis.
    analysis  bitvec                 // Locally cached result of JUMPDEST analysis

    Code     []byte
    CodeHash common.Hash
    CodeAddr *common.Address
    Input    []byte

    Gas   uint64
    value *big.Int
}