texts:
The blockchain is all about serverless and removing the third party. But I saw many DAPPs accessible through HTTP. Isn't this breaking the serverless concept? I read in a lot of places that IPFS aims to replace HTTP to make the web decentralized.
How can browsers like Google Chrome run DAPPs that using protocols such as Whisper?
What is the point of Mist Browser if I can access DAAPs through any other browsers(using HTTP)?


texts: How do I install an OLD version of Geth and Swarm?

texts:
I need to install an old version of Swarm : version 1.7.3-stable , but I can't figure out how to install it from the command line.

I'm on Mac OSX.

I've found these old downloads: https://geth.ethereum.org/downloads/ but I can't figure out how to install them on my machine. I'd prefer to install from source, if possible.

I can only manage to install the latest versions of geth and swarm:

$geth version
Geth
Version: 1.8.14-stable
Architecture: amd64
Protocol Versions: [63 62]
Network Id: 1
Go Version: go1.10.3
Operating System: Darwin
GOPATH=/Users/me/go
GOROOT=/usr/local/Cellar/go/1.10.3/libexec

$swarm version
Swarm
Version: 0.3.2-stable
Go Version: go1.10.3
OS: Darwin

However, these latest versions aren't compatibile with the code of the project I've just joined.

The team I've joined are using Geth 1.7.3 and Swarm 1.7.3 (note that it appears Swarm version numbers used to coincide with Geth version numbers, but have since separated, as you can see with my versions above). I need to revert both Geth and Swarm back to 1.7.3 on my machine.

Is there a way to clone and install an old version from a github repo? Any help appreciated!


texts: send raw transaction without knowing nonce

texts:
I want to send raw transactions but I don't want to accidentally overwrite any transactions.

Afaik when using eth.sendTransaction it automatically increments the nonce and doesn't overwrite any transactions (is the node keeping track of the nonce here?). Now I have a script that sends raw transactions to a node (no account listed there for security reasons, obviously).

Is there a way to automatically append transactions without knowing the nonce or accidentally overwriting transactions? Or do I have to keep track of the nonce myself?


texts: What is the recommended way to build Ethereum wallet ?

texts:
What is your recommendation for building hosted Ethereum wallet, where we manage private keys.

Among other questions :

Do we store private keys on in the DB or keep them in the node ?
If we are storing them in the DB, do we have to import them every time client need to perform transaction, then remove them ?
if the node is running on different server than the App, what is the best way to connect ?

This is new field, any ideas where there we can find guidance for this ?


texts: I'm reviewing the crowdsale template, am I reading this correct?

texts:
I'm reading the crowdsale template, and I'm wondering if I'm reading certain things correctly.

Okay, the first part I want to ask about.

 /* checks if the goal or time limit has been reached and ends the campaign
 */    function checkGoalReached() afterDeadline {

This section looks like a simple date deadline function, using a new variable
couldn't we also determine if some one trys to buy tokens BEFORE the crowdsale? Something like
StartTime = now + 1 years - 50 weeks,
 meaning this crowdsale is going to start in 2 weeks from now?
 (https://solidity.readthedocs.io/en/latest/units-and-global-variables.html)

Q1: Wouldn't this be a good approach for these ICOs? This way they can publish their real crowdsale address before the ICO begins?

I know some people lost a lot of ETH because of poorly communicated token addresses...

Q2: This part confuses me as well, is it used for freezing eth? Are ETH going into this contract address available to the creator? Or does that have to be specifically coded into the contract?

   function safeWithdrawal() afterDeadline {
        if (!fundingGoalReached) {
            uint amount = balanceOf[msg.sender];
            balanceOf[msg.sender] = 0;
            if (amount > 0) {
                if (msg.sender.send(amount)) {
                    FundTransfer(msg.sender, amount, false);
                } else {
                    balanceOf[msg.sender] = amount;
                }
            }
        }   if (fundingGoalReached && beneficiary == msg.sender) {
            if (beneficiary.send(amountRaised)) {
                FundTransfer(beneficiary, amountRaised, false);
            } else {
                //If we fail to send the funds to beneficiary, unlock funders    balance
                fundingGoalReached = false;
            }
        }
    }   }

I appreciate the time and answers. I have an idea I'd like to try to make happen, its not life changing and not meant to be the next big thing... I just really want to learn.

I guess what I'm trying to accomplish is a smart contract that will allow me to pull the ETH at any time, and that will provide participants with a flat rate of exchange for a new token. Anyone have any examples? The code is fairly easy to read, just trying to find resources at this time.


texts:
Im currently testing my contract and I've written truffle tests in js for the first time. Rarely (1 out of 10 times?) I get unexpected results:

This is the code structure I use:

var contract = artifacts.require("./Contract.sol");
var otherContract = artifacts.require("./otherContract.sol");
var instance;
contract("DevToken", accounts => {

    before(async() => {
        instance = await contract.deployed();
    });

    it("init test", async() => {

        var contractAddress = await instance.getAddress.call();

        assert.equal(contractAddress, otherContract.address,
        "address: " + contractAddress + " should be equal to " + otherContract.address);
    });

    // e.g. balance in contract is 0.5 ETH
    // function toWei() is defined as web3.toWei(x,"ether")
    it("should test balance", async() => {

        await instance.withdraw(toWei(0.5),{from:accounts[0]});

        var allowanceBalance = await instance.allowanceBalance.call();

        assert.equal(toWei(0.5), allowanceBalance.toNumber(),
        "should have allowanceBalance of " + 0.5 + " ETH, actual allowanceBalance: " + fromWei(allowanceBalance) + " ETH");

    });

});

basically what happens is that when testing initial variables set in the constructor or testing variables after a contract call, sometimes the test fails and shows me the previous state before the call (or 0 in case a constructor variable fails). Then I change nothing and run the test again and everything is fine.

Example of an assertion error output where I set an address in the constructor:

AssertionError: address: 0x0000000000000000000000000000000000000000 should be equal to 0xb5ed2d3af7d0efa5ba6f805ae633f6516003f5e2: expected '0x0000000000000000000000000000000000000000' to equal '0xb5ed2d3af7d0efa5ba6f805ae633f6516003f5e2'

Example of an assertion error when I withdraw from a balance

AssertionError: should have allowanceBalance of 0 ETH, actual allowanceBalance: 0.5 ETH: expected 0 to equal 500000000000000000

in the second example the withdrawal goes through and 0.5 eth get sent to my wallet, so everything works as expected, only the test doesn't. It seems as if sometimes, the previous contract call isn't finished calculating and updating stuff yet and the second call to check the values is already fetching the variable states. It kinda ignores the await purpose.

To clarify again: The tests work 90% of the time (without changing stuff), so there should be no error with my contracts and unless I am calling stuff wrongly, there should be no error with my tests either.)

I'm using ganache as my testrpc, btw.

Is there some inconsistency with truffle js tests? Why does this happen? Is there a way to fix this?


texts:
I have read a lot about smart contracts and also have seen lots of implementation tutorials. But there are some ambiguous points in it that I can’t investigate it completely.

For example: Imagine we have a dapp and its contracts have been deployed. (E.g in ethereum mainnet)

Here are my questions:

1- When we deploy our contracts, does it mean that every node that belongs to the main ethereum network has access to it and must execute it?

2- So does it mean that we have lots of smart contracts in the ethereum blockchain and all of nodes have to execute all of them at the same them?

3- Imagine that person A has deployed smart contracts of his dapp on ethereum and we have done that too. So now there are two different dapps with different contracts in ethereum. Does it mean that we can have a block in ethereum that have a transaction from the first dapp and another transaction from the second dapp? (In other words, I mean whether or not the transactions of different dapps are mined together even if they are from different dapps?)


texts: What is a "bound" function in a Solidity contract?

texts:
When a deployed contract is shown in Truffle, some functions show up as

[Function: bound]


texts:
While everyone can create a token, this one seems to have attracted a lot of value from third party users (current ether balance place it in the top 500 and with more than 9000 users).

By disassembling the bytecode, it definitely seems not be a wallet contract… But does someone have more informations about the project ? I mean the source code or how to use the contract ?


texts:
The RLP specification says the following about integers:

  The only purpose of RLP is to encode structure; encoding specific atomic data types (eg. strings, ints, floats) is left up to higher-order protocols; in Ethereum integers must be represented in big endian binary form with no leading zeroes (thus making the integer value zero be equivalent to the empty byte array).

When it says "in Ethereum" does this actually mean in the ETH subprotocol alone, or does this mean in the body of work 'Ethereum' and specifically the RLP protocol? If the latter, this paragraph seems to contradict itself. On the one hand, it is saying that RLP leaves the encoding to higher protocols, but on the other says that RLP demands big endian integers with all leading zeroes skipped.

Where should this encoding be implemented then? In the RLP protocol, or should there be a specific type 'EthereumInteger' distinct from 'integer'?

Perhaps a better question might be, to whom should this sort of question best be addressed and where?


texts: "truffle migrate --network ropsten" stuck after compiling

texts:
I am trying to redeploy a contract on Ropsten Testnet using the command:

truffle migrate --reset -f 1567182283 --network ropsten

Here, "1567182283" is the prefix of my migration file. Upon executing, it gets stuck after compiling the contract:

Compiling your contracts...
===========================
> Everything is up to date, there is nothing to compile.

I even left it overnight but there was no message or anything, it just gets stuck like this for more than 6-7 hours. Below is my truffle-config.js:

const HDWalletProvider = require('truffle-hdwallet-provider');
const fs = require('fs');
const mnemonic = fs.readFileSync(".secret").toString().trim();
module.exports = {
  // rpc: {
  //   host: "localhost",
  //   port: 8545
  // },
  networks: {
    development: {
      host: "127.0.0.1",     // Localhost (default: none)
      port: 9545,            // Standard Ethereum port (default: none)
      network_id: "*",       // Any network (default: none)
      websockets: true
    },
    ropsten: {
      provider: new HDWalletProvider(mnemonic, "https://ropsten.infura.io/v3/KEY"),
      network_id: 3,       // Ropsten's id
      gas: 550000000,        // Ropsten has a lower block limit than mainnet
      networkCheckTimeout: 1000000000,
      timeoutBlocks: 200,
      skipDryRun: true,
    },
    rinkeby: {
      provider: function() {
        return new HDWalletProvider(mnemonic, "https://rinkeby.infura.io/v3/KEY");
      },
      network_id: 4,
      networkCheckTimeout: 1000000000,
      timeoutBlocks: 200
    }
  }
}

Any way to solve this problem?
I have tried running the command without --reset and -f as well but still the same.


texts: Why With Truffle, token is not verified in bsc test network?

texts:
As seen on the screen, I did the build process, but the verification process fails. I got the API key, I entered but it is not working Where am I making a mistake?
address: https://testnet.bscscan.com/address/0xDd24215EEE88bae02A6d241834eC59284942236A


texts:
Fast summary: Need a faucet-like funcionality in my private blockchain to give Ether to the newly on-demand created wallets from Android Dapp.
I'm working in a project where I've deployed a totally private and customized blockchain, with a bunch of smart contracts to interact with and an Android Dapp to manage the communciation with both (SC and BC).
The problem comes with: When I firstly sign-up in my Dapp, a wallet account in the blockchain is created (with WalletUtils and loadCredentials), but to start interacting with the Smart Contracts I need (fake) Ether, so I'm looking for a solution where either kind of private faucet or any way to get Ether from the brand new created wallet is implemented. I tried without success the next approaches:

Set the mining coinbase to the Smart Contract with the goal of having a big supply of Ether in the contract, and a function into it called giveMeEther() where 10 Eth is transferred to msg.sender. I configured --miner.gasPrice '0' to be able to call this function from Android without Ether but is not working: java.lang.RuntimeException: Intrinsic gas too low (although from geth console I managed to send transactions with gasPrice 0 from main account) Problem: I still need a first amount of Ether to call this function or manage to send gasPrice 0 transactions from Android with the new wallet.

Create a master account (or a bunch of them) in the genesis block with (almost) infinite Ether and keep mining to get unlimitted Ether in this account(s), and from the Dapp, after log into one of this accounts (because I know its credentials), call Transfer.sendFunds() with 10 Eth to the newly created wallet. Problem: I need to log-in in the code, with the plain-text password to a master account, and that's a big security bug (even though I obfuscated the code, it's still not a good practice). This solution works fine because a new wallet is created with 10 Ether succesfully, but now the problem is about security and about to give the credentials to this master accounts to anybody, that could log in and give all the amount of Ether available in those accounts to itself and get all the project crashed.

The solution of create X accounts initially in the genesis block with predefined Ether does not fit here because I'll need on demand accounts with ether and I'm not knowing how many accounts there will be.

I also thought in the solution of trying a testnet like Ropsten/Rinkeby instead my own private blockchain and call faucet, but I will lose the advantages of configuring from scratch my own blockchain, and if I'm not wrong, I'll have to pay to finally deploy my Smart Contracts to the main testnet.

So the ideal solution would be to implement an exact same funcionality as faucet but for my own blockchain.
I'll be so grateful with any help. Thanks.


texts:
Can anyone decrypts cipher-text using Public Key? as I know we can only decrypt using private key, but in this  RLPx documentation what this line means?

Receiver receives the initiator handshake and decrypts it with its own public key.

are they talking about verifying signatures?


texts:
I am trying to do a small example contract of

Error deploying required libraries: Invalid bytecode format.

Here is the contract code

library CounterLib {
struct Counter {
    uint i;

}

 function incremented(Counter storage self) returns (uint) {
    return ++self.i;
 }
}

contract CounterContract {
   using CounterLib for CounterLib.Counter;

   CounterLib.Counter counter;

   function increment() returns (uint) {
     return counter.incremented();
   }
}


texts: Running full node. Why is chaindata folder > 300GB?

texts:
I'm running a full node with Mist and my chaindata folder is huge. It's over 300GB when the block-chain is currently just over 100GB. There's over 169,000 files. Is that normal?

Is there a way to recover what I already have instead of just deleting it all and re-syncing?


texts: Solidity: How to do 2D mapping?/Syntax Error

texts:
I am getting a syntax error. I am not sure if its a problem related to 2D mapping or 2D array. My code is given below:
contract Stealing{

   mapping (address => uint) balances;
   mapping (address => bool) frozenAccount;
   mapping (address => uint) allowed;
   function transferFrom ( address from , address to , uint value )public returns ( bool success ) {
      // checking account is freeze or not
      if( frozenAccount [ msg. sender ]) return false ;
         // checking the from should have enough coins
      if( balances [ from ] < value ) return false ;
         // checking for allowance
      if( allowed [ from ][ msg. sender ] >= value ) return false ;
         // checking for overflows
      if( balances [to] + value < balances [to ]) return false ;
      balances [ from ] -= value ;
      allowed [ from ][ msg . sender ] -= value ;
      balances [to] += value ; // Notify anyone listening that this transfer took place
      transferFrom (from , to , value );
    return true ;
 }
}

The error message is:

prg9.sol:37:11: Error: Indexed expression has to be a type, mapping or
array (is uint256)
if( allowed [ from ][ msg. sender ] >= value ) return false ;

Somebody please guide me.
Zulfi.


texts: Sign an NFT asset with an Ethereum address

texts: Is it available an Ethereum application that allow the owner to let "sign" his NFT asset by other addresses? If not would it be possible to develop it?


texts: Using smart contracts for delivering encrypted data

texts: How can I utilise (perhaps automate) a smart contract to deliver some encrypted data from A to B, based on the pre-requisite that A fulfills B's requirements. Would I need an oracle for this type of interaction and if so, how could such communication successfully be rolled out?


texts:
Created Daemon process from the Link
The parameter in the config.toml Configuration file is not working in the System Service and geth configuration is working with default configuration.

[Service]
Type=simple
ExecStart=geth -config=/home/ubuntu/.ethereum/config.toml

How can I run it as go-ethereum as daemon process / service on Ubuntu with Toml file?


texts: Call Smart Contract Function in Python Script

texts:
My situation is reverse to most. I am relatively experienced in coding in Solidity, but have absolutely no experience in using Python.

What I would ideally like to do is have a script that will, in predetermined time intervals, call a Smart Contract Function and give it the required input, then read and possibly store the output.

I need help figuring out the "calling the function" part. Please dont just point me to web3.py, I looked it over and while it seems very useful I dont know where to start and I dont have the time to take it from the top right now. If you could provide some help specifically on what I am asking for, please do.

Thank you.


texts: what wallet and payment methods to use in Africa?

texts:
So my question is very simple :
I live in Morocco and I wanna know what coin-based websites support my country ?


texts: Can the mapping storage change after contract deployment?

texts:
I am beginner in mapping.I work on Truffle and Ganache. I deploy the following contract:
pragma solidity ^0.5.12;
contract customerFinder{
    mapping(uint256 => address payable) public addressStorage;

    function filling(uint256 iden, address payable sender) public{
       addressStorage[iden]=sender;
    }

    function finder(uint256 id) public view returns(address payable){
       return addressStorage[id];
    }
}

Ganache shows the storage of the contract:

After that, i run the filling() function by truffle:

And a new block created. But, i expect the contract's storage be changed and no change occurrs.

Is there any problem or my expectation is false?


texts: Unable to set custom gas limit for Oraclize query

texts:
I have an Oraclize query like the following:

function __callback(bytes32 myid, string result) onlyOraclize {
    // do things
    update();
}

function update() payable onlyOwnerOrOraclize {

    string memory part1 = "[URL] ['json(https://api.random.org/json-rpc/1/invoke).result.random.data.0', '\\n{\"jsonrpc\":\"2.0\",\"method\":\"generateIntegers\",\"params\":{\"apiKey\":${[decrypt] BAKDeam1gVg++DgtVnOA3WuDkzbAaRgY4xOXmdvSQSteMyI94gNWyWcc0uDpVJtikYyzClR6Kvw5xbEswpJryBwNirC7sKsP23rQovooh1xQxBlId6cNgwb5UBzidOB0dVvl7EntjRxRZmSVBihSjpSEa7TRPjU=},\"n\":1,\"min\":0,\"max\":";

    string memory maxRandomNumber = uint2str(3);

    string memory part2 = ",\"replacement\":true,\"base\":10${[identity] \"}\"},\"id\":1${[identity] \"}\"}']";

    string query = strConcat(part1, maxRandomNumber, part2);

    bytes32 rngId = oraclize_query(60, "nested", query);

}

While I have a contract with plenty of Ether in it, the default gas limit for Oraclize calls (200000) isn't enough (unless I comment out update(); in the callback so the query only runs once). Per the docs (https://docs.oraclize.it/#ethereum-quick-start-custom-gas-limit-and-gas-price) setting the gas limit should just be the 4th parameter in the oraclize_query. But if I try the following (to set gas at 500000):

bytes32 rngId = oraclize_query(60, "nested", query, 500000);

The query doesn't get run at all. Why would this be?

As a sidenote, without a nested query with encrypted API key, and just doing it as follows:

oraclize_query(60, "URL", "json(https://api.random.org/json-rpc/1/invoke).result.random.data.0", '\n{"jsonrpc":"2.0","method":"generateIntegers","params":{"apiKey":"my-api-key","n":1,"min":0,"max":3,"replacement":true,"base":10},"id":1}');

200000 gas is enough for it to run as many times as it needs as long as the contract has Ether in it. But with a nested/encrypted query it needs more gas.


texts: How to be sure about "MetaMask web3 Provider" connection?

texts:
Note: This question is related to this : "Updated :" How to see "output" of "web3.personal.sign" in "browser"? ("Method personal_sign not supported")

I do following steps to sign a message using web3.personal.sign. However, I am not to MetaMask. (Note: apparently, web3.personal.sign is not supported by testRPC.)
Here are steps that I do:

(1) I open cmd and run testrpc

(2) I click on MetaMask icon and selecting localhost 8545

(3) I select one of private keys generated by testrpc

(4) I select import account from MetaMask and paste this private key in text box of Paste your private key string here

(5) now balance of this address is 100 eth

(6) I insert this address (public key) in web3.personal.sign function to sign the message (Please see the full code below)

(7) I open html file by Google Chrome

(8) I receive this messages : No web3? You should consider trying MetaMask! and  Error: Method personal_sign not supported. Here is screen shot: https://ibb.co/i93oRy

Here is the full code for signing a message using web3.personal.sign:

<!doctype html>

<html lang="en">
<head>
  <meta charset="utf-8">
  <title>EthereumJS - Browser Example</title>
</head>

<body>
  <script src="https://rawgit.com/ethereumjs/browser-builds/master/dist/ethereumjs-abi/ethereumjs-abi-0.6.5.js"></script>
  <script src="https://rawgit.com/ethereum/web3.js/develop/dist/web3.js"></script>
  <script src="https://cdn.jsdelivr.net/gh/ethereum/web3.js/dist/web3.min.js"></script>

  <script>

window.addEventListener('load', function() {

   // Checking if Web3 has been injected by the browser (Mist/MetaMask)
  if (typeof web3 !== 'undefined') {
    // Use Mist/MetaMask's provider
    web3 = new Web3(web3.currentProvider);
  } else {
    console.log('No web3? You should consider trying MetaMask!')
    // fallback - use your fallback strategy (local node / hosted node + in-dapp id mgmt / fail)
    web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
  }

//  var Web3
//  web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));

  function constructPaymentMessage(contractAddress, amount)
  {
  return ethereumjs.ABI.soliditySHA3(
    ["address", "uint256"],
    [contractAddress, amount],
  );
  }

  var message = constructPaymentMessage("message to be signed", 100);
  console.log(message);

  web3.personal.sign("0x" + message.toString("hex"), "0x01e7D1D50804fDc2fD5A134081076A8E487Ca747", function(err, signature) {
  console.log(signature);
  console.log(err);
  // Be sure to make use of the signature only here.
  // It will not be defined until this callback is invoked.
});

})
  </script>
</body>
</html>

Apparently, I am not connected to MetaMask and if so, How can I solve this problem?

Here is screen shot of MetaMask when is opened and connected to localhost 8545 (As you can see the balance of testRPC address is 100 eth) :


texts:
Using web3 under nodejs I suddenly want to unlock my account before calling a DAO contract function:

var Web3 = require('./node_modules/web3/lib/web3');

// dont override global variable
if (typeof window !== 'undefined' && typeof window.Web3 === 'undefined') {
   window.Web3 = Web3;
}

module.exports = Web3;

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

var accounts = web3.eth.accounts;
web3.personal.unlockAccount(accounts[0], "mypassword", 2);
console.log("yay")

But then I get this error:

/home/andres/Documents/Code/Crypto/ethWithdrawer/node_modules/web3/lib/web3/requestmanager.js:61
        throw errors.InvalidResponse(result);
        ^

Error: The method personal_unlockAccount does not exist/is not available
    at Object.module.exports.InvalidResponse (/home/andres/Documents/Code/Crypto/ethWithdrawer/node_modules/web3/lib/web3/errors.js:35:16)
    at RequestManager.send (/hhome/andres/Documents/Code/Crypto/ethWithdrawer/node_modules/web3/lib/web3/requestmanager.js:61:22)
    at Personal.send [as unlockAccount] (/home/andres/Documents/Code/Crypto/ethWithdrawer/node_modules/web3/lib/web3/method.js:145:58)
    at Object.<anonymous> (/hhome/andres/Documents/Code/Crypto/ethWithdrawer/approver_test.js:77:15)
    at Module._compile (module.js:410:26)
    at Object.Module._extensions..js (module.js:417:10)
    at Module.load (module.js:344:32)
    at Function.Module._load (module.js:301:12)
    at Function.Module.runMain (module.js:442:10)
    at startup (node.js:136:18)

Or this other error in other box:

/home/user/Code/Crypto/ethWithdrawer/node_modules/web3/lib/web3/requestmanager.js:61
throw errors.InvalidResponse(result);
^

Error: personal_unlockAccount method not implemented
at Object.module.exports.InvalidResponse (/home/user/Code/Crypto/ethWithdrawer/node_modules/web3/lib/web3/errors.js:35:16)
at RequestManager.send (/home/user/Code/Crypto/ethWithdrawer/node_modules/web3/lib/web3/requestmanager.js:61:22)
at Personal.send [as unlockAccount] (/home/user/Code/Dao/ethWithdrawer/node_modules/web3/lib/web3/method.js:145:58)
at /home/user/Code/Crypto/ethWithdrawer/web3caller.js:33:19
at Array.forEach (native)
at Object.<anonymous> (/home/user/Code/Crypto/ethWithdrawer/web3caller.js:23:10)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)

What's the problem? The function is there, I can see it by doing console.log(web3.personal).


texts:
I tried to generate nonce using this formula, so I can avoid 'underpriced' problem and nonce conflicts

nonce: web3.utils.toHex( Math.round (Date.now() / 1000 - 1586000000)  ),

But simply these transactions are been refused ( I am using Infura rpc)

Why?

Actually it generates number like 365158. Not so great I think...


texts: What are the hex outputs in a truffle migrate?

texts:
I am testing on accounts and addresses and I am trying to understand the hex outputs in truffle. I have this -

Running migration: 2_deploy_contracts.js
  Replacing CA10...
  ... 0x7563df6c873b68c4337487146dd0ff438a7dd61bb44c7fe10b84d53a398af2ba
  CA10: 0xd2af90a472ab8ac41cad694c06fc60b0b72f54be
Saving successful migration to network...
  ... 0x11c062f191b5627641f93030c496d3c9e3ce59bdd4da17802e4798a600782f71
Saving artifacts...

I understand that 0xd2af90a472ab8ac41cad694c06fc60b0b72f54be is the contract address. But I am unsure about the other numbers. Are these some kind of keys?


texts: Why does the ERC20 Token wiki example subtract the balance of address(0) to calculate total supply?

texts:
When reading the ERC20 Token Standard in the Wiki, I've noticed that in its Sample Fixed Supply Token Contract, the value of balances[address(0)] is subtracted from the contract's total supply to calculate the total supply.

Here's what totalSupply() looks like at the time of writing this question:

function totalSupply() public view returns (uint) {
  return _totalSupply.sub(balances[address(0)]);
}

To give more context, _totalSupply is created when the contract is instantiated and .sub() is a library function from SafeMath:

contract FixedSupplyToken is ERC20Token {
  using SafeMath for uint;

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

  constructor() public {
    decimals = 18;
    _totalSupply = 1000000 * 10**uint(decimals);
    balances[owner] = _totalSupply;
  }
}

Now there are two things to me that are unclear:

Considering that at the time of creating the contract, only balances[owner] should have the value of _totalSupply, why are we interested in balances[address(0)] in the first place?
Assuming that there's zero value in balances[address(0)] anyways, why is totalSupply() subtracting it every time from _totalSupply?


texts:
I am running a mocha test for a solidity SC.  One of my test function should pass and then, just after that i am calling assert(false), but it is not executing.

 it('only manager can call the pickWinner', async () => {
try {
  await lottery.methods.pickWinner().call({
    from: accounts[1],
  });
  assert(false);
} catch (err) {
  assert(err);
}});

The test is passing even though I am doing assert(false).


texts:
To what extent will Casper affect transaction prices?

Seems like it wouldn't affect gas amounts, but that it would lower the gas prices, owing to the lower costs of operating the network.


texts: Are API tokens incompatible with Ethereum apps?

texts:
I want to build an Ethereum app that gets weather data from a trusted (government run) API via oracilize. This service requires an API token to be sent with each request to prevent abuse. Each API token is limited to a per-second and per-day number of requests.

It is free to make a call to their API, and getting an API token is free. You just enter your email address into a form, and they immediately email you a token.

Hard coding an API token into the contract won't work, because an attacker can take the token and spam their API over the per second rate, causing my app to break.

I was thinking that I could do a convoluted thing where I get oracilize to create an AWS instance, which would in turn programmatically create an email account with some free service (not sure if this is actually possible), provide the new email address to the API token creation form, and then get the token from the email address's inbox and make an API call. This would have to happen every time an API call needs to be made.

But I wonder if even that is still insecure? Like maybe an attacker could subscribe to an event and could still manage to get the token and spam the API before I can get the data I need.

Are API tokens completely incompatible with ethereum apps? Or is there some way around this issue.


texts: How to generate public key from private key in Rust?

texts:
How to generate Ethereum public key from private key in Rust?

I found rust-secp256k1 and it seems to be what I need, but there is no documentation at all, which makes this crate for me, Rust newbie, nightmare.

Appreciate any help.


texts:
Is there any way or library to have a set in solidity that can be iterated like C++'s std::set?

    library Set {
  // We define a new struct datatype that will be used to
  // hold its data in the calling contract.
  struct Data { mapping(string => bool) flags; }

  // Note that the first parameter is of type "storage
  // reference" and thus only its storage address and not
  // its contents is passed as part of the call.  This is a
  // special feature of library functions.  It is idiomatic
  // to call the first parameter `self`, if the function can
  // be seen as a method of that object.
  function insert(Data storage self, string memory value)
      public
      returns (bool)
  {
      if (self.flags[value])
          return false; // already there
      self.flags[value] = true;
      return true;
  }

  function remove(Data storage self, string memory value)
      public
      returns (bool)
  {
      if (!self.flags[value])
          return false; // not there
      self.flags[value] = false;
      return true;
  }

  function contains(Data storage self, string memory value)
      public
      view
      returns (bool)
  {
      return self.flags[value];
  }
}

This is an implementation I found but this struct can not be iterated


texts: Can host nodes trust smart contracts? Can smart contracts trust their hosts?

texts:
Is it safe for the hosting node to run smart contract? What if someone writes a malicious contract and try to give instructions the hosting node?
Can smart contracts trust hosting nodes? Hosting nodes will have full visibility on what is happening during runtime. Can smart contracts safely handle sensitive information?
Is there "sandboxing" around Solidity to prevent this kind of malicious interference?


texts: Data integrity after Go Ethereum crashes

texts: If my Geth node crashes during normal sync or --fast sync, can the integrity of the node's blockchain database be guaranteed or is there a risk that some transactions or even blocks (in the case of a --fast sync) didn't get written to the node's filesystem?


texts: Smart contract will not deploy to my private blockchain when using Remix IDE

texts:
So I'm a complete newbie and trying to deploy my first smart contract to a local Ethereum blockchain. I'm doing this on a Windows machine.
I have created a private blockchain using geth, made an account and started mining. The account is unlocked.
This is the command I use to start the node:
geth --datadir "%my_node_path%" --rpc --rpcport 8545 --rpccorsdomain "*" console 2>console.log

Then I installed the remix-ide node module and created a simple smart contract.
It compiles, so no problem there.
In order to connect the Remix IDE to my blockchain, I changed the environment to Web3 provider. Seems that the connection works as the account ID shows up correctly and the ether amount updates as I mine.

Now, if I listen on the network, the console shows the mined blocks, but when I try to deploy my contract, the Remix console shows this:

creation of greeter pending...
[block:1746 -  0 transactions]

Then if I do txpool.status from the command line on my blockchain, it doesn't show the transaction:

txpool.status {   pending: 0,   queued: 0 }

Why isn't the smart contract deploying? I am strictly following a tutorial. Have been trying to find an answer for the past day, with no luck.


texts:
I am creating contracts similar to VM error: revert. revert The transaction has been reverted to the initial state. Note: The called function should be payable if but combined with the restricting access common pattern in solidity. For the functions in MainContract I have a modifier onlyBy as well as for the functions in SubToken.
The only difference between the two contracts, in regads to restricting access, is that for the MainContract I have:
initiator = 0xf57596949E8ee597e4D1464706a49CD71FB25AdF;
executor = msg.sender;

And for the SubToken I have:
initiator =  msg.sender;
executor = 0xf57596949E8ee597e4D1464706a49CD71FB25AdF;

My problem is that I want the initiator of SubToken to be the same address as the executor in MainContract, otherwise it gives me the error sender not authorized. I tryed to switch the initiator =  msg.sender;  to initiator = tx.origin; on SubToken but that only makes the the initiator and executor to have the same address (0xf57596949E8ee597e4D1464706a49CD71FB25AdF).


texts: I'm trying to create an ether token and getting this error


texts: Couldn't understand the error message: ParserError: Expected ';' but got '(' Constructor Survey (address _owner) payable public

texts:
pragma solidity 0.5.0+;
contract Survey {
    /* Events */
     event SurveyInitialized(address indexed owner, uint indexed surveyReward);

    /* Contract State */
    address public owner;
    address private factory;

    Constructor Survey(address _owner) payable public {
        (_owner != address(0));
        (msg.value > 0);
        owner = _owner;
        factory = msg.sender;
        emit SurveyInitialized(owner, msg.value);
    }
}

the error :

  browser/checkbalance.sol:12:20: ParserError: Expected ';' but got '('
  Constructor Survey (address _owner) payable public


texts: What is the Proof of Stake and how this concept is (or will be) related with Ethereum?


texts: Create custom mobile wallet for my two ERC20 Tokens

texts:
I have two ERC20 tokens that I created on Ethereum.
I would like to know if it is possible for me to create a mobile application that will allow my users to check their balance (for tokens) and transfer them tokens, a kind of wallet app, if possible with multisig functionality...


texts: when does a transaction get registered / included in a block

texts:
I want to know when does a transaction gets registered in a block ?
Is there any queue type of structure where the transactions get stored before getting included in a block by miner ???
As in let's say if i have transferred 1 eth to my friend and announce that transaction to the block chain, how much time will it take to get included in a block and block to get attached to the block chain ?
And also on what basis miners select which transactions to include in the block, is it on the first come first serve basis ? And if they don't want my transaction to get included in the block they are about to mine then in that case what happens to my transaction and the amount of ether i have send to my friend ???


texts:
I have a node synched in normal mode up until number=5143444

Node started with

geth --datadir "./"
--rpc
--rpcaddr 0.0.0.0
--ws
--wsaddr 0.0.0.0
--wsorigins="*"
--maxpeers 100
--maxpendpeers 10
console

I'm trying to test the geth traces (compared to parity traces) but it seems I cannot get old transactions.

I've tried running trace on a recent transaction and it works

> debug.traceTransaction("0x59ae735c0291ec79460968d01dbd5b4adf007571bfaa308b8ab1005bb5e3f500")
{
  failed: false,
  gas: 21000,
  returnValue: "",
  structLogs: []
}

But if I try running trace on an older transaction (from block 1580796), I get this

> debug.traceTransaction("0x8e5b38db03e0941677ba65275d78fe18df999c11a7be1921831082121ae73390")
Error: required historical state unavailable
    at web3.js:3143:20
    at web3.js:6347:15
    at web3.js:5081:36
    at <anonymous>:1:1

I know with parity I need to specifically set tracing and archive on:

--tracing=on
--pruning=archive

And this creates a HUGE database. Is there something similar for geth?
The command line options don't seem to have anything about this


texts:
Is it possible to call Uniswap from a smart contrat and make a swap with smart contract ether, and not from the message sender ether ? (and send back the swapped token to the owner)
I tried like this on Kovan testnet but it failed :
pragma solidity ^0.8.2;
import "https://github.com/Uniswap/uniswap-v2-periphery/blob/master/contracts/interfaces/IUniswapV2Router02.sol";

contract Coffre{

  address owner =msg.sender;

  IUniswapV2Router02 uni = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);

  address private token_address = 0x514910771AF9Ca656af840dff83E8264EcF986CA; //chainlink

  function getPathForETHtoToken() private view returns (address[] memory) {
     address[] memory path = new address[](2);
     path[0] = uni.WETH();
     path[1] = token_address;
   return path;
   }

  function swapContractEthToLink() public {
  uni.swapExactETHForTokens(0,getPathForETHtoToken(), owner, block.timestamp + 15);
  }

Also with swapExactETHForTokens I can't specify how many Eth from the contract I want to swap so it's probably not the right function


texts: IPFS code needing extra JS Scripts with Solidity

texts:
So I created a truffle folder for solidity, wrote down the basic test.js and ipfsContract.sol needed (Creating a form in IPFS for users to enter data). HOWEVER, on doing truffle test I get 0 passing in green, although I do ask test.js to print out the hash code!

[I also do one edit in test.js -
const IPFS = require('ipfs')  // importing IPFS module and instantiating it.
const node = new IPFS()]

Reading various articles on the net, I am thinking if I need to create an extra .js file outside the truffle directory to make it work. But I could be wrong!
ANy help?


texts:
I mined some Ethereum before the DAO hardfork. At the time I didn't really understand what the hardfork meant. I just went with the flow and updated the software and I didn't realize I also received coins on the Ethereum Classic network. Now that I do, I would like to access them. But I don't know where to start.

While mining, the ETC was sent to a contract, not an account. And in my ETH wallet, I can't see the contract. I remember deleting or cancelling the contract after I transferred all the received mined coins. But this was on the ETH network, not the ETC network. I looked up the ETC contract address on gastracker.io and it still has the ETC balance I expected. The contract  belongs to the wallet I still have the keystore file for. I just don't know how to access this contract to transfer the coins on the ETC network.

I would really appreciate it if somebody could point me in the right direction. Thank you very much for your time.


texts: what tools/services would you recommend for pulling metadata from ERC721 contracts? It seems like it's going to be a huge hassle to return the metadata directly from the blockchain. Any clever ideas?


texts: Chain txvm vs EVM: Specified Differences

texts: Chain txvm vs EVM: What are the specified differences between both platforms?


texts:
I have this code and it gives me infinite gas. please help me improve it.

pragma solidity ^0.4.23;
// v6
contract owned {

    constructor() public { owner = msg.sender; }
    address owner;

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

}

contract mortal is owned {
    function kill() public onlyOwner {
        selfdestruct(owner);
    }
}

contract StudentCertificate is owned, mortal {

    struct Certificate {
        bytes32 title;
        bytes32 courseName;
        bytes32 issuedBy;
        bool _isRekoved;
    }

    struct Student {
        uint16 id;
        bytes32 name;
        uint certificateCount;
        mapping(uint => Certificate) certificates;
    }

    mapping(address => Student) public students;

    function addStudent(bytes32 _name, address _studentAddress, uint16 _userUId) public onlyOwner {
        require(students[_studentAddress].id==0);
        students[_studentAddress] = Student({
            id: _userUId,
            name: _name,
            certificateCount: 0
        });
    }

    function removeStudent(address _studentAddress) public onlyOwner {
        require(students[_studentAddress].id!=0); // save gas
        // first delete certs if any
        for(uint i = 0; i < students[_studentAddress].certificateCount; i++){
            delete(students[_studentAddress].certificates[i]);
        }
        delete(students[_studentAddress]);  // will save gas. gas refund
    }

    function addStudentCertificate(address _studentAddress, bytes32 _title, bytes32 _courseName, bytes32 _issuedBy) public onlyOwner {
        require(students[_studentAddress].id!=0);
        students[_studentAddress].certificates[students[_studentAddress].certificateCount] = Certificate({
            title: _title,
            courseName: _courseName,
            issuedBy: _issuedBy,
            _isRekoved: false
            });

        students[_studentAddress].certificateCount++;
    }

    function getStudentCertificateCount(address _studentAddress) public view returns (uint256){
        return students[_studentAddress].certificateCount;
    }

    function getStudentCertificateData(address _studentAddress, uint256 _certArrayIndex) public view returns (bytes32, bytes32, bytes32, bool){
        return (
            students[_studentAddress].certificates[_certArrayIndex].title,
            students[_studentAddress].certificates[_certArrayIndex].courseName,
            students[_studentAddress].certificates[_certArrayIndex].issuedBy,
            students[_studentAddress].certificates[_certArrayIndex]._isRekoved
            );
    }

}

Error/Warning message by Remix:

Gas requirement of function StudentCertificate.addStudent(bytes32,address,uint16) high: infinite. If the gas requirement of a function is higher than the block gas limit, it cannot be executed. Please avoid loops in your functions or actions that modify large areas of storage (this includes clearing or copying arrays in storage)


texts: I am learning IPFS these days and curious about if any company is using IPFS to save data. When we upload file into IPFS, we get a hash and can use the hash to get access to the file content. But in our application, we may want to update the file. Do we just grab the file and update the content?


texts: Updating inflationary token values per block?

texts: Let's say within a specific smart contract, that deals with updating tokens values (due to inflation) on an exchange, the main way of consistently updating is utilizing a preset multiplier called in various methods. I've been toying with how I could go about having the inflationary values updated on a per block basis and ridding myself of the need for the multiplier all together. What would be the best way to implement something like this?


texts: SmartContract determine timestamp of saving data

texts:
I have really simple solidity smartcontract for saving and fetching data structs.
When I ask for data struct (fetching function) I need to know timestamp (or block ID) when was the struct saved. How to accomplish that?

Saving timestamp as part of struct data seems really stupid to me...

PS: I am developing in C# and Nethereum

Thanks


texts: Is there any chainlink adapter that provides decentralized time-stamp service? I searched the Chainlink market; however, I couldn't find it.


texts: Other cryptorurrency use in smart contracts

texts: Is it possible to use other cryptocurrency than Ether (for example, Bitcoin, Litecoin etc.) within Ethereum smart contracts? I can imagine this will not really be compatible except for other currency being burned? (read I will provably burn Bitcoin and the smart contract will give me some Ether for it?)


texts:
I am trying to wire my smart contract with Oraclize to get random numbers. Here's my contract code:

pragma solidity ^0.4.2;

import "./usingOraclize.sol";

contract Blackjack is usingOraclize{

   uint public random;

   event Paid(address indexed _from, uint _value);

   function() external payable {
       Paid(msg.sender, msg.value);
   }

   function Blackjack() public {
       OAR = OraclizeAddrResolverI(0x6f485C8BF6fc43eA212E93BBF8ce046C7f1cb475);
   }

   function getRandom() public constant {
       oraclize_newRandomDSQuery(0, 4, 200000);
   }

   function __callback(bytes32 _queryId, string _result, bytes _proof) public{
        random = uint(keccak256(_result)) % 52 + 1;
   }
}

I am using Ganache as a private blockchain (GUI).

Calling getRandom() causes the following stack trace in the truffle console

Error: Invalid JSON RPC response: {"id":12,"jsonrpc":"2.0"}
at XMLHttpRequest._onHttpResponseEnd (C:\Users\adimi\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\xhr2\lib\xhr2.js:509:1)
at XMLHttpRequest._setReadyState (C:\Users\adimi\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\xhr2\lib\xhr2.js:354:1)
at XMLHttpRequestEventTarget.dispatchEvent (C:\Users\adimi\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\xhr2\lib\xhr2.js:64:1)
at XMLHttpRequest.request.onreadystatechange (C:\Users\adimi\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\web3\lib\web3\httpprovider.js:128:1)
at C:\Users\adimi\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\truffle-provider\wrapper.js:134:1
at C:\Users\adimi\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\web3\lib\web3\requestmanager.js:86:1
at Object.InvalidResponse (C:\Users\adimi\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\web3\lib\web3\errors.js:38:1)

I have also sent 3 ether to the contract to cover for the Oraclize call.

Edit: I have set up ethereum-bridge and it is running when I get the error.


texts: Can I add ICO functionality to a final contract code?

texts: I'm thinking to add ICO functionality directly to my final contract code. Is it worth it? It's just compares time. If current time is > than ICO time, then it's works like a normal project and all ICO functions are disabled. Asking because i'm afraid to do something wrong.


texts: How can I query data from contract storage?

texts:
If I have a contract like below:

contract wallet{

   mapping (address => uint) balances
   function send(){...}
   ......

}

and I deploy this contract on the ethereum.

When I want to query the balances for example check the balance of Alice, is there any api to do this query directly like SQL.


texts: Prediction Market (result publishing issue)

texts:
I am trying to create e prediction market where people can contribute in predicting (which side is going to win?) by spending Ether, but unfortunately i am getting error ("Error: invalid BigNumber string") as an owner to publish the result to smart contract in order to unlock the claim function for gamblers to collect their gains.I have to specify the winner and loser side in my reportResult() function, also i have set my input types there to "Side" refers to my enum at the beggining.I'm not sure what to type in reportResult() input field in Remix to submit the winner and loser side.
Can anyone help me with this issue?
contract prediction {

    enum Side { A, B }

    struct Result {
        Side WINNER;
        Side LOSER;
    }

    Result public result;

    uint public counter;

    bool ended;

    address private owner;

    constructor() {
        ended = false;
        owner = msg.sender;
    }

    modifier onlyOwner {
        require(msg.sender == owner, "You cannot access this part");
        _;
    }

    mapping(Side => uint) public sideCounter;

    mapping(Side => uint) public bets;

    mapping(address => mapping(Side => uint)) public betsPerGambler;

    function placeBet(Side _side,uint _Amount) public payable {
        require(ended == false, "Unfortunately accepting bets is over!!");
        bets[_side] += _Amount;
        betsPerGambler[msg.sender][_side] += _Amount;
        sideCounter[_side] += 1;
        counter += 1;
    }

    function claim() public {
        uint gamblerBet = betsPerGambler[msg.sender][result.WINNER];
        require(gamblerBet > 0, "You don't have any winning bet sir!!");
        require(ended = true, "Game is not over yet sir!");
        uint gain = gamblerBet + bets[result.LOSER] * gamblerBet / bets[result.WINNER];
        betsPerGambler[msg.sender][Side.A] = 0;
        betsPerGambler[msg.sender][Side.B] = 0;
        payable(msg.sender).transfer(gain);
    }

    function betClosed() public onlyOwner {
        ended = true;
    }

    function reportResult(Side _winner,Side _loser) public onlyOwner {
        require(ended = true, "Close accpeting the bets first sir!!");
        result.WINNER = _winner;
        result.LOSER = _loser;
    }
}


texts: When Mining on Testnet do I need to Sync again?

texts:
I have fully synced Mist and have now switched to Test-Net and it appears the Sync process has begun again.

Is this now syncing the Test environment?
if so then follow no:2
Can I only begin mining once the sync completes and -
Can I switch back to the main network without losing what has already
synced in the Test-Net?

Thanks


texts: Progamming contracts in Ethereum, is it safe?

texts:
I am completely new to Ethereum.
I read a lot of articles and have a question.
As far as I understood, one can develop smart contracts in Ethereum that are like executable programs. In these programs one can make a transaction.

For example I want to send 5 Ether to Bob. This is a transaction. Now, I am going to develop a program that compiles on EVM and in this program I send 5 Ether to Bob.

Now my question: I can code anything I want. If I have only 5 Ether in my balance, but I am going to spend 500 Ether to Bob, who will read and check my code and decide how many Ether I can spend or not ? In Bitcoin nodes or miner can check the blockchain and look, how many Bitcoin you have spent and you still have.


texts: Ethereum - Missing semi-colon whilst using script from Udemy

texts:
I am trying to learn how to create contracts using a course in Udemy that my work provides. I am following the steps 1 by 1 but am receiving the following error. Any help would be appreciated
Error:

Expected token Semicolon got 'eth_compileSolidity'
        Function TCoin(int256 initialSupply) {
                  ^

Code:

pragma solidity 0.4.8;
contract TCoin{
        mapping (address => uint256) public balanceOf;

        Function TCoin(int256 initialSupply) {
          //balanceOf[Msg.sender] = initialSupply;
        }

        Function transfer(address _to, uint256 _value){
        balanceOf[msg.sender] -= _value;
        balanceOf[_to] += _value;
        }
}


texts:
2 days ago when i open my ether wallet i notice that all of my ether is stolen

about 25 ether

my addres is 0xbE50d343BC815C424a5bD3abf7B3046fe4f491c9

and the hacker addres is 0x1896172cF718A14680BC62c0dB3a0223408cc10b

please help me??/

really all of my ether is gone?


texts: How do I use filter EVM log events by an indexed field in web3j?

texts:
I've looked through the documentation, but there doesn't seem to be this scenario listed. What I want to do is filter the Ethereum event log of a specific contract by an indexed field with Web3j.

Example solidity code: event someEvent(bytes32 indexed id, bytes value);

While we can get all the events within a specific time period using EthFilter filter = new EthFilter(startBlock, endBlock, contractAddress);, and filter for a specific event type by using the Event class, how do I get all events of a specific type that match an indexed field (for example, where id == {0, 0, 0 ... 0})?


texts:
Trying to deploy the newly created contract into rinkeby test network but got struck with the below error. Please check the code, error message and package.json details below.

const HDWalletProvider = require('truffle-hdwallet-provider');
const Web3 = require('web3');
const {interface, bytecode} = require('./compile');
const provider = new HDWalletProvider(
'frog almost employ roast protect host citizen festival rural alone document misery',
'https://rinkeby.infura.io/v3/560e70f3ebfc4f628a53f4143b9460fd'
);
const web3= new Web3(provider);
const deploy = async () => {
    const accounts =  await web3.eth.getAccounts();
    try {
        const contractDeployment = await new web3.eth.Contract(JSON.parse(interface))
        .deploy({ data: '0x'+ bytecode, arguments: ['Hi there! I am inside Rinkeby'] })
        .send({from: accounts[0] });
console.log(contractDeployment.options.address);

    } catch (error) {
        console.log(error);
    }

};
deploy();
======================================================================
Error:
(node:58876) UnhandledPromiseRejectionWarning: Error: Subscriptions are not supported with the CustomProvider.
    at CustomProvider.subscribe (C:\BlockChain\node_modules\web3-providers\dist\web3-providers.cjs.js:1139:13)
    at NewHeadsSubscription.subscribe (C:\BlockChain\node_modules\web3-core-subscriptions\dist\web3-core-subscriptions.cjs.js:52:43)
    at NewHeadsWatcher.watch (C:\BlockChain\node_modules\web3-core-method\dist\web3-core-method.cjs.js:180:110)
    at C:\BlockChain\node_modules\web3-core-method\dist\web3-core-method.cjs.js:50:31
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
(node:58876) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:58876) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Error: Invalid JSON RPC response: ""
=======================================================================
Package.Json
  "dependencies": {
    "ganache-cli": "^6.2.3",
    "mocha": "^5.2.0",
    "solc": "^0.4.25",
    "truffle-hdwallet-provider": "0.0.6",
    "web3": "^1.0.0-beta.37"


texts:
I am trying to set up my own private network using GETH. I have a limited number of miners right now. Currently, 2 miners are running. I experienced quite slow in performing transactions. I added up extra 3 miners but there is no significant change in performance and it's still slow.
How can I increase the performance level of my private network? Isn't it miners and gas price that does?


texts:
Hi I'm trying to unlock an account using web3 but it returns empty error. When I use cli it returns true

> personal.unlockAccount(eth.accounts[0])
Unlock account 0xd80433523782e421f3b474d0dbb2b0fb682b6ac6
Passphrase:
true

In web3 I'm using like

 web3.eth.personal.unlockAccount(user['ethId'], config.adminPass, 1000).then(val => {
        console.log(val);
 }).catch(error => {console.log(error)}); //error is always empty

What should I do to unlock account via web3?


texts: How to create your own ERC 721 NFT token

texts: I am trying to create my own ERC-721 non fungible token and unable to find any docs, basic code and how to deploy it on a testnet. Could someone share the official specification and an example of how to implement an ERC-721 token?


texts:
I am trying to send ether from one address to another. After executing the code I am receiving an error: Cannot read property 'then' of undefined. How can I fix this? Thanks in advance.

const Web3 = require('web3')
const Tx = require('ethereumjs-tx').Transaction
const web3 = new Web3(new Web3.providers.HttpProvider('https://mainnet.infura.io/'))

const addressFrom = 'addr1'
const privateKey = Buffer.from('key', 'hex')
const addressTo = 'addr2'

const txData = {
  gasLimit: web3.utils.toHex(25000),
  gasPrice: web3.utils.toHex(10e9),
  to: addressTo,
  from: addressFrom,
  value: web3.utils.toHex(web3.utils.toWei('0.0002', 'ether'))
}

function sendRawTransaction(txData){
  web3.eth.getTransactionCount(addressFrom).then(txCount => {
    const newNonce = web3.utils.toHex(txCount)
    const transaction = new Tx({ ...txData, nonce: newNonce }, { chain: 'mainnet' })
    transaction.sign(privateKey)
    const serializedTx = transaction.serialize().toString('hex')
    return web3.eth.sendSignedTransaction('0x' + serializedTx)
  })
}

sendRawTransaction(txData).then(result =>
  result
    .on('transactionHash', txHash => {
      console.log('transactionHash:', txHash)
    })
    .on('receipt', receipt => {
      console.log('receipt:', receipt)
    })
    .on('confirmation', (confirmationNumber, receipt) => {
      if (confirmationNumber >= 1) {
        console.log('confirmations:', confirmationNumber, receipt)
      }
    })
    .on('error:', error => {
      console.error(error)
    })
)


texts: What command in solidity is same as "in" in Python

texts:
I want to use a for loop for all the values of p in the array returned by the function prime (with parameter n).
Below is how to do it in Python, but I can't figure how to do it in Solidity...

for p in prime(n):
    // rest of code

Here's the solidity code:

function factorization(uint256 compositeNumber, uint256 limit) constant returns(uint256 pp){
    uint256 g = compositeNumber;
    uint256 x1 = 16;
    uint256 y1 = 5;
    uint256 z1 = 1;
    while (g == compositeNumber){
        g = greatestCommonDivisor(4 * a**3 + 27 * b**2, compositeNumber);
    }
    if (g > 1){
        return g;
    }
    for(uint256 i = 1; i <= limit; i++){ //Might be a problem
        if (i in prime(limit)){          //Problem is here
        pp = i;
        while (pp < limit){
            (x1, y1, z1) = _ecMul(i, x1, y1, z1);
            if (z1 > 1){
                return greatestCommonDivisor(z1, compositeNumber);
            }
            pp = i * pp;
        }
        }
    }
}

function prime(uint256 limit) constant returns(uint256[] memory primes){
    primes = new uint256[](limit +1);
    for (uint256 i = 2; i < limit; i++){
        primes[i] = i;
    }
    i = 2;
    while(i**2 <= limit){
        if (primes[i] != 0){
            for (uint256 j = 2; j < limit; j++){
                if (primes[i] * j > limit){
                    break;
                }
                else {
                    primes[primes[i] * j] = 0;
                }
            }
        }
        i++;
    }
    for (i = 2; i <= limit; i++){
        if (primes[i] != 0){
            primes[i];
        }
    }
}

Thank you!


texts: Genesis file config parameters represents

texts:
Can anybody help me to understand or a reference link to understand below keys mentioned in config parameter of genesis file

 "config": {
   "chainID": 68,
   "homesteadBlock": 0,
   "ByzantiumBlock" : 0,
   "eip155Block": 0,
   "eip158Block": 0
 }


texts: Can we remove queued transaction in geth pool (PoA)?

texts:
Is there a way to limit time of queued transaction or remove them ?

I am using PoA network (Geth)


texts: how to parse the value returned by truffle? from balanceOf()

texts:
My question is nearly identical to: how to parse the value returned by truffle ?

Except that when I run:

bigNumberValue.toString()

i get

'[object Promise]'

but then if I treat as a promise and run:

bigNumberValue.toString().then(a=>{console.log(a)})

I get

balance1.toString(...).then is not a function

I am running Truffle v4.1.12 (core: 4.1.12). I am trying to get the value out of the BigNumber. Can anyone help?


texts: How to `truffle migrate` to private permissioned network?

texts:
I am running a private permissioned network and would like to use Truffle v5.0.1 for deployment. I use it according to the documentation:

Compile my project with truffle compile so that the ./build folder with the appropriate json files appears.
Deploy my project with truffle migrate --network private, BUT:

I get an error:

  Error: Number can only safely store up to 53 bits.

Here is my deployment script:

My 1_initial_migration.js looks as follows:

var Migrations = artifacts.require("Migrations");
var MyTokenContract = artifacts.require("MyTokenContract");

module.exports = function(deployer, network, accounts) {
    deployer.deploy(Migrations, {from:accounts[0], gas: 4500000, gasPrice:0});
    deployer.deploy(MyTokenContract, "arg1", "arg2", {from:accounts[0], gas: 4500000, gasPrice:0});
};

I have set up a network object whithin the truffle-config file named private:

private: {
  provider: () => new HDWalletProvider(myPrivateKey, `http://ip_address_to_network:22000`),
  port: 22000,
  network_id: "*",
  from: "0x....",
  production: true
}

EDIT:
If I use HDWalletProvider(myPrivateKey, http://ip_address_to_network:22000) without the port specification 22000 in the URL, then I don't get the above error! Then it seems that everything works fine, but I get NO return or confirmation at all on the console. How do I find out whether the migration worked?


texts:
I attempted to purchase what I thought was EOS tokens 2 days ago. Now I'had a look and found two transactions for 0.2 and 1 ether but don't know what address it is for.

TxHash: 0x81ae7065961eaabfd098bc792fa5d2e4ce33d0bdb66276b910d5f8c111971847

Block: 4674826

Address from: 0xf809849f38ec935ea211a7aeb9e86da56568a662

Address to: 0x9ba5ae67fd01a2d21cb662961f70cd29dbbcc886

For the second transaction (1 ether):

TxHash: 0xd96bb9bcf56417f1cba401cd1134c25f4ac4d499483bc8edc29ee0d088651db1

Block: 4674874

Addresses are the same.

I would be grateful for any advice on how I can confirm if this is indeed an EOS address.

Thanks


texts: Factory Contract Function is not creating New Contract using testrpc and web3

texts:
I am new to DApp development. I have deployed a TokenFactory contract and that Factory contract has a function "Create New Token" that generates a new token contract.
The function "Create New Token" is working fine in remix IDE but I need to attach a GUI with this.
All other functions are working fine with GUI but when i click on the "Create New Token" but it is giving me error.
Below is the Factory Contract Code :

    pragma solidity ^0.4.18;

    import "./TestToken.sol";
    //import "./NewCrowdsale.sol";

    contract FactoryToken {

      // index of created contracts

      address[] public contracts;

       mapping (address => bool) created;
      //Crowdsale public theObj;
      address newContract;

      string public  name ;
      string public  symbol ;
      uint256 public  decimals ;

      // useful to know the row count in contracts index

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

       function setToken(string _Name, string _Symbol, uint256 _Decimal) public {
          name = _Name ;
          symbol = _Symbol;
          decimals= _Decimal;
       }

       function getToken() public constant returns (string,string, uint256) {
           return (name, symbol,decimals);
       }

      // deploy a new contract

       function newToken() public returns(address objAddress)
  {
       newContract = new WILDToken(name,symbol,decimals);
   contracts.push(newContract);

        return newContract;

  }

       function verify() public constant returns (address) {
            return newContract;
        }
      //function GetAddress() public view returns (address) {

       // return (c);
      //}
    }

And here is the code that i have written for testrpc and web3

I have a button, and by clicking on that button it calls the newToken function to create a new token contract which is now giving me error.

 $("#create").click(function () {

           Coursetro.newToken(3,{from:web3.eth.accounts[0],gas: 470000});
        });

Any Help will be appreciated. Thanks


texts:
I am running a local geth node (--fast --rpc) and executing the following code in a local Nodejs program:

https://gist.github.com/admazzola/79daee3b41e47596e36286464b1d98dd

Strangely, it works but that loop runs extremely slow and each function call takes about one whole second to resolve.  Once it gets up in the 2 or 3 thousands it usually locks up or freezes up and I don't know why that is.  Is there a better way to pull all of this data and store it in a dictionary or is this the best way?  Why is it so slow if I am just gathering local data?


texts:
I am trying to understand what it means when someone mentions that their product is 'based off' or 'added' to the Ethereum blockchain.

I am new and trying to get a handle of this:

Why have a new coin if its based off/added to the ethereum blockchain?
If a new coin is based off the Ethereum blockchain, does it make sense to only buy Ether? Seeing as the new coin is based off Ether. If the new coin's price rises, ether's  price is bound to rise as well.
Lets say all these new coins can be mined, do we need a special miner for all these coins? Can I use just 1 miner? If yes, how does the miner know what coin it has found?


texts: Why do some blocks contain no transactions?

texts: While poking through my Geth logs I noticed that block 1,000,006 doesn't actually contain any transactions. Why is that?


texts: can we pay the gas price in form of token?

texts: can we pay the gas price in form of ERC20 token without using the ether? if ERC20 token has a value.then can we pay the gas price in form of ERC20 token.


texts: Trying to send transaction on next block

texts:
I'm trying to understand block time and speed of transaction. For now I'm testing on Binance Smart Chain and then I will go to ethereum network.
I have a simple code in nodejs using web3 library, I'm connected to a node via websocket :

I subscribe to 'newBlockHeaders' events
Once I get a new block I use  web3.eth.accounts.signTransaction and web3.eth.sendSignedTransaction to send a test transaction

My transaction is ALWAYS 2 blocks after the received block event. I want it to be 1 block after.
Looks like confirmation time is about 6 sec so 2 blocks makes sense. But how to place my transaction on just 1 block after the event received?


texts: how i know what function run the trasaction?

texts:
i have that question , how i know what function runs the transaction ?,

let me explain , if i do a transaction in remix.ethereum i can see the transaction in the bottom and in the details of this i see the next example for "to:" :

to: myContract.createForm(address,uint256,string,string,string[],string[],string[],string[])

but if i see the same transaction in the etherscan rinkeby i only see something like this :

To: Contract 0x41072cdd4817179e3e08c9a5a8c83e58b80bdf29

and is correctly but they don't show what function is running, i wanna know how i can get that data to see in my front app what function is running that transaction, i am try with "getTransaction" from web3 but this not show me what function runs

if anyone can help me i would really appreciate.


texts: Metropolis and Byzanium and node syncing


texts:
I'm quite new to etherium development, so most probably I'm doing smth wrong. I have a ganache running locally, a contract deployed there and I want to build a small app to get familiar with the process.
I've chosen Vue for the app development and currently I ran into a problem with web3 connection to the ganache.

In my root component I create an instance of Web3:

const etherUri = 'http://127.0.0.1:7545'

let web3 = new Web3(Web3.currentProvider)

if (!web3.isConnected) {
    return 'Unable to connect to ethereum node at ' + etherUri
} else {
    let accounts = web3.eth.accounts
    return accounts
}

Ganache is up and running, Metamask connects to it without any problems. However, trying to connect from my app I always get isConnected = false.

The app runs as a npm run dev server. No errors in console.

I don't use js that much, so probably there are some mistakes in my setup. Any clues would be highly appreciated. Thanks in advance!


texts: How do I call a function into a contract with solidity and want to continue execution even if this call reverts?

texts:
I have looked into the Solidity docs but cannot seem to find this feature. I want to call into a contract and want to push two values onto the stack: the actual return value AND if the execution completed or not (in the sense that a CALL-like opcode puts 0 on the stack).

The only way it seems to be doable is writing inline assembly, but this gets rather tough if the function I am calling is returning a dynamic sized bytes variable. I know that it is possible, of course, but I find it rather surprising that solidity does not have this feature.


texts: Mist 0.8.6: Cannot execute transaction on function when sending Ether as msg.value

texts:
I have the following problem in Mist 0.8.6:
When sending a transactions to the function of a contract without ether (in msg.value) the function executes and I see value changes in the contract.

When sending the same transaction with ether (in msg.value) it seems the function won't be called (at least I don't see any value changes in the debug variables of the contract...).

The transaction with ether does not show any errors, it seems to execute fine.

The complete code of the contract is quite a lot; below you fined the code of the function that I call (it's a fork of the DAO-Wars game).
When I call the function without sending ether the debug variable "debug_add_creature" is set to "before if, ether_cost_ether" (as expected), variable "debug_ether_costs" is set to "2000000000000000000". When I call the funciton with sending ether nothing changes...

Note that Mist displays the warning "It seems this transaction will fail, it may consume all the gas you send."; but when I set the gas manually to 4000000 it does execute (without showing any errors in the transaction).
Previously I could run the function with sending ether, this is a recent problem.

Any suggestions?

Is the problem, that the transaction takes too much gas?

      function add_creature(address brain, string species_name) returns(uint) {
uint eth_cost = (eth_deposits * eth_amount) + starting_eth;

/* convert wei to either, because the incoming msg.value is in ether! */
// Note: Can be optimized to just multiply with the 1000000000000000000 instead of ** 18
uint eth_cost_ether = eth_cost * 10 ** 18;
uint starting_eth_ether = starting_eth * 10 ** 18;

debug_add_creature = "before if, ether_cost_ether";
debug_msg_value = msg.value;
debug_ether_costs = eth_cost_ether;

if (msg.value >= eth_cost_ether) {
  debug_add_creature = "in if, before add creature";
  Creature creature = creature_builder.build_creature();
  debug_add_creature = "in if, creature";
  uint location = _random_empty_location();
  uint species_id = num_species++;

  board.add_creature(location, creature);
  this.register_creature(creature);
  /* The species should not always be created new, but creatures of a certain species
           should be added to that species upon creation (if the user is the same) */
  debug_add_creature = "in if, before new species";
  NewSpecies(species_id, species_name, creature);
  species.length++;
  species[species_id].name = species_name;
  species[species_id].creatures.push(creature);

  debug_add_creature = "in if, species done, set creature";
  creature.set_eth(starting_eth_ether);
  creature.set_brain(brain);
  creature.set_location(location);
  creature.set_hp(3);
  creature.set_board(board);
  creature.set_species(species_id);
  creature.set_creature_builder(creature_builder);
  creature.set_game(this);
  creature.set_admin(admin);

  debug_add_creature = "in if, creature done, send money...";

  test=creature.send(starting_eth_ether);
  test=board.send(msg.value - starting_eth_ether);
  board.deposit_eth(eth_deposits, eth_amount);

  debug_add_creature = "in if, money sent, return";

  /* Quick fix: we return the index-number of the creature-species that was created
           So the user can retrieve the creature's address by function all_creatures_for_species. */
  return species_id;
}

}


texts: Getting address of a new contract in truffle with javascript?

texts:
I am trying to use truffle-contract and web3 to create a new instance of a contract and then get the contract address of the contract that I just created.
I have tried the following code with a few similar variations but I get an error of the form "Cannot set property 'contractInstance' of undefined"
I understand it can take a few minutes to create the contract but how do I factor this into the code?
What is the recommended way to do this, or best practice?
  createNewContract(value) {
    return new Promise((resolve, reject) => {
      const contract = require('@truffle/contract');
      const transferContract = contract(tokenAbi);
      transferContract.setProvider(that.web3);
      transferContract.new({from: account}).then(function(instance) {
        this.contractInstance = instance.address;
        return instance.address;
      }).then(function(status) {
        if (status) {
          return resolve({status: true});
        }
      }).catch(function(error) {
        console.log(error);
        return reject('new contract error');
      });
    });
  }

Thanks


texts:
Getting familiar with the geth client and within some code followed a tutorial (HERE) to transfer tokens from an address. When I check the transaction on EtherScan, it has failed:

https://rinkeby.etherscan.io/tx/0xf53488d996a532ae78080a23c54384c8f58438db02130f039b0e08dacf760f86

Not quite sure how to debug this and would appreciate any pointers on this.

Here is copy of my code

package main

import (
    "context"
    "crypto/ecdsa"
    "fmt"
    "log"
    "math/big"

    ethereum "github.com/ethereum/go-ethereum"
    "github.com/ethereum/go-ethereum/common"
    "github.com/ethereum/go-ethereum/common/hexutil"
    "github.com/ethereum/go-ethereum/core/types"
    "github.com/ethereum/go-ethereum/crypto"
    "github.com/ethereum/go-ethereum/crypto/sha3"
    "github.com/ethereum/go-ethereum/ethclient"
)

func main() {

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

    privateKey, err := crypto.HexToECDSA("49be7f9b459942977f07f99653b5b042144baefa092c5ac833d6ec9893a5b8dd")
    if err != nil {
        log.Fatal(err)
    }

    publicKey := privateKey.Public()
    publicKeyECDSA, ok := publicKey.(*ecdsa.PublicKey)
    if !ok {
        log.Fatal("error casting public key to ECDSA")
    }

    fromAddress := crypto.PubkeyToAddress(*publicKeyECDSA)

    nonce, err := client.PendingNonceAt(context.Background(), fromAddress)
    if err != nil {
        log.Fatal(err)
    }

    value := big.NewInt(0) // Transfering Tokens doesnt need ETH values

    //gasLimit := uint64(21000)

    gasPrice, err := client.SuggestGasPrice(context.Background())
    if err != nil {
        log.Fatal(err)
    }

    toAddress := common.HexToAddress("0x4592d8f8d7b001e72cb26a73e4fa1806a51ac79d")

    tokenAddress := common.HexToAddress("0x28b149020d2152179873ec60bed6bf7cd705775d")

    transferFnSignature := []byte("transfer(address,uint256")

    hash := sha3.NewKeccak256()

    hash.Write(transferFnSignature)

    methodID := hash.Sum(nil)[:4] // read up go lang slices

    fmt.Println(hexutil.Encode(methodID))

    paddedAddress := common.LeftPadBytes(toAddress.Bytes(), 32)
    fmt.Println(hexutil.Encode(paddedAddress))

    amount := new(big.Int)
    amount.SetString("1000000000000000000000", 10)

    paddedAmount := common.LeftPadBytes(amount.Bytes(), 32)

    fmt.Println(hexutil.Encode(paddedAmount))

    var data []byte

    data = append(data, methodID...)
    data = append(data, paddedAddress...)
    data = append(data, paddedAmount...)

    gasLimit, err := client.EstimateGas(context.Background(), ethereum.CallMsg{
        To:   &toAddress,
        Data: data,
    })
    if err != nil {
        log.Fatal(err)
    }

    fmt.Println(gasLimit)

    /*
        Generate Transation Type
    */

    tx := types.NewTransaction(nonce, tokenAddress, value, gasLimit, gasPrice, data)

    /*
        Signing Tx with Sender's Private Key
    */

    signedTx, err := types.SignTx(tx, types.HomesteadSigner{}, privateKey)
    if err != nil {
        log.Fatal(err)
    }

    /*
        Broadcasting Transaction to Network
    */

    err = client.SendTransaction(context.Background(), signedTx)
    if err != nil {
        log.Fatal(err)
    }

    fmt.Printf(" tx sent: %s\n", signedTx.Hash().Hex())

}


texts: Will I receive my Ether? Transferred to my wallet while the Etherum wallet was downloading

texts:
So I was super excited to get the etherum wallet downloaded, I followed all the steps. As I set it up, after the part where you set your password it prompted me to fund my wallet with ether. I then went to my poloniex account and sent all my ether from that account to the address provided in the set up of my ether wallet. After it was "successfully" sent from poloniex I went back to wallet, hit next and then the next screen came up: "downloading the blocks." I had assume that the deposit screen was the last screen in my setup. My question is, will I see my ether in my account after the blocks have been downloaded and the wallet is fully set up? From my polo account it says that my ether has been successfully sent, but obviously I can't see it because the blocks are downloading (my wallet is being set up)

PS,
This is my first time downloading this etherum wallet. Appreciate your assistance in answering my question.

-Noob


texts: How to make buyer of my NFT pay the gas fee for minting?

texts: I want to set up a dApp where i sell create and sell my own NFT's. Is it possible to put the gas fee's onto the buyer so they pay for all the gas? And how would i do that if so?


texts: How can I confirm validity of deployed contract?

texts:
I have deployed contract using mist browser 0.6.1

How can I do code validity check on ethereum mist?


texts: Can the Ethereum ecosystem exist without the DNS and HTTP protocols?

texts:
I understand that DNS/HTTP is needed right now to serve the Dapps through human-readable names (e.g., mkr.market), but very soon it seems like this will be possible with a combination of ENS and Swarm (or alternative decentralized protocols).

Is there any other part of the core ethereum protocol that depends on DNS or HTTP?


texts:
I recently stumbled across ds-math's rpow() being a O(lg n) safe implementation of exponentiation.
Such a function is ultimately created because the EVM EXP opcode is unsafe wrt. overflows. The strategy is that since we're multiplying, we'll detect any overflows incrementally using a safe rmul(). (The "r" part supposedly refers to how it rounds.)
But I wonder why it isn't the case with EXP that you can create some invariant that asserts no overflows.
I thought that one might simply check that either the exponent is 0, or the result is greater-than-or-equal to the base. But what if the exponent is so great that it wraps around the word size and lands above the base, or wraps around the word size twice and lands above the base?
In another vein, I don't think you can easily do any modulo checks, since overflows conform to modular semantics.
So my question is: Has anyone tried to perform a safe exponentiation using EXP or ruled out the possibility?
The opcode is only 10 gas, after all.


texts:
In my application players can create and join games. I store every game in a mapping(uint => Game), and send out a GameCreated event whenever a game is created. My issue is efficiently getting a list of open (not yet joined) games on the client side.

I could iterate through all Game objects and filter out those that have been joined, but this is not scalable. At first I thought that listening for GameCreated events would help, but I'd still have to filter out using GameJoined events, since I don't think I can modify logs that have been logged already. This has the same scalability issue. I could mitigate it by only getting logs from the past week or whatever, but I don't really like this option.

I considered making a dynamically sized array where each item is the game id of an open game, but in order to update this list I'd need to be able to delete entries when a game was joined, which would require storing the index in each Game object. But then when an entry was deleted, all those other game objects would need to be updated with the new index and it's just a mess.

Ideally this application will get a lot of traffic some day, so I kind of need an efficient solution. Is there something obvious I'm missing here? Are there any better workarounds you've come across? I wish I could iterate through a mapping with only the currently open games, but I don't think that's possible.


texts: Why are there missing opcodes when using the disassembler on bytecode from the blockchain?

texts:
I'm using the disassembler from go-ethereum repo which fails on about 20% of the bytecode from the blockchain with missing/unknown opcodes.
The disassembler on Etherscan fails as well.

Is there an up-to-date disassembler with complete opcode tables that can be used? Am I doing something wrong?

Examples of failed disassembly -

0x52ecf69544784165101e76a682eeea642e72584d
0x4432979c7c6bdd19f9ef20787c4ac9cc9710667b


texts: Truffle. Type index error (Error: Error: VM Exception while executing eth_call: invalid opcode)

texts:
I have got error if i try call method  getArrayData()

contract ManagerDb {

    struct ManagerStruct {
        bytes32 firstname;
        bytes32 lastname;
        bytes32 email;
        uint index;
    }

    mapping ( address => ManagerStruct ) Managers;
    address[] public managerIndex; // Managers

    function insertManager(
        address managerAddress,
        bytes32 firstName,
        bytes32 lastName,
        bytes32 email
    )
        returns (bool)
    {

        ManagerStruct memory newManager;
        newManager.firstname = firstName;
        newManager.lastname = lastName;
        newManager.email = email;
        newManager.index = managerIndex.push(managerAddress)-1;

        Managers[managerAddress] = newManager;
        return true;
    }

    //for example
    function getArrayData() constant returns (bytes32[] _data1) {

        uint arrLength = managerIndex.length;
        bytes32[] memory arrData1 = new bytes32[](arrLength);
        for (uint i=0; i <= arrLength; i++){
            address addr = managerIndex[i];
            ManagerStruct ms = Managers[addr];
            arrData1[i] = ms.firstname;
        }

        return (arrData1);
    }
}

An error occurs if I substitute the index [i]. When i use constant number managerIndex[0] and here arrData1[0] it work. What am I doing wrong
But if i use function getManager :

function getManager(uint index) constant returns (bytes32, address){
    ManagerStruct ms = Managers[managerIndex[index]];
    return (ms.firstname, managerIndex[index]);
}

I do not get error.


texts: Best way to process withdrawals for ETH?

texts:
New to ETH. Designing a web-wallet type of service. Currently generating new deposit address keypairs via web3.eth.personal.newAccount(). Iterating each block via web3.eth.getBlock(), and scanning the transaction array for transactions where tx.to == <deposit address>. Watching for confirmations based on block height, using web3.get().eth.subscribe('newBlockHeaders').

This all seems to work fine, but I can't seem to easily figure out the best way to process withdrawals. I need to provide a from address when calling web3.eth.sendTransaction({from, to, value})

User balance is not linked to their deposit amount, it can change. So, is the best way to process a withdrawal to sweep all deposits to a common account address? What's the best way to do this? (i.e. gas considerations, etc)


texts: How to host a blockchain decentralised application?

texts:
Till now, I have worked on centralised application in which there is one web server and one database server. Now when I started exploring about block-chain, I came to know that it is a decentralised application. Now, question arises in front of me is, how to host a block-chain decentralised application?

It might be a silly question but here i want to understand this concept more deeply.

Please help to clear my above query.

Thanks


texts: Please provide example for web3.currentProvider

texts:
The following document states that "MetaMask is going to continue to inject the ethereum provider as web3.currentProvider for the forseeable future.":
https://github.com/MetaMask/faq/blob/master/detecting_metamask.md

That document indicates that using the web3.currentProvider object will NOT require importing a convenience library like Web3 or EthJS. I will only have to add the following code to the onLoad event:

if (typeof web3 !== 'undefined') {
    // Use the browser's ethereum provider
    var provider = web3.currentProvider
} else {
    console.log('No web3? You should consider trying MetaMask!')
}

Therefore, please provide two specific tested examples using the provider.sendAsync(options, callback) method that was described on the above webpage.

For example, if the contract contains a "Deposit()" function that is marked as "payable", please provide the correct conversion of the following JS call:

myContractInstance.Deposit.sendTransaction({from:"0x3d86B4D6f28554428E5AF38490DD1977691A3082", value: web3.toWei(0.2,'ether')}, function(error, result){
    if(!error) {
        console.log("#" + result + "#")
    } else {
        console.error(error);
    }
})

If the contract contains a "getLastDepositor()" function that returns a stored value, please provide the correct conversion of the following JS call:

myContractInstance.getLastDepositor.call(function(error, result){
    if(!error) {
        console.log("##" + result + "##")
    } else {
        console.error("Error:" + error);
    }
})

My project will not allow the installation of Web.js or Ethjs. If specific Javascript files can be downloaded to a Windows machine, and then uploaded to a Linux server, that is allowable. However, any libraries that require an npm installation are not allowed. The reason for this is that the final website must be easily uploaded to any server, without requiring a package installer.


texts: tokenMock.mint is not a function(tokenMock is the deployed Smart Contract)

texts:
I am creating a new Blockchain wallet with ERC20,but during migration,i am getting the error that tokenMock.mint is not a function(tokenMock is the deployed contract)
I am sending the tokens to my account,and then calling the smart Contract with the same account,as it is showing that tokenMock.mint is not a function,so the tokens are not being transferred and hence the balance is 0.


texts: Getting Tx is not a constructor when executing this program

texts:
Here is my code. I am trying to send ether from one account to another.

var Tx     = require('ethereumjs-tx')
const Web3 = require('web3')
const web3 = new Web3('https://ropsten.infura.io/v3/1ac73a4112ab456cb5bdd3ac33e4fe82')

const account1 = '<Account 1>'
const account2 = '<Account 2>'

const k1 = Buffer.from('<Private key 1>','hex')
const k2 = Buffer.from('<Private key 2>','hex')

web3.eth.getTransactionCount(account1,(err,txCount)=>{
    //building a transaction
    const txObject = {
    nonce:    web3.utils.toHex(txCount),
    to:       account2,
    value:    web3.utils.toHex(web3.utils.toWei('0.1', 'ether')),
    gasLimit: web3.utils.toHex(21000),
    gasPrice: web3.utils.toHex(web3.utils.toWei('10', 'gwei'))
  }

  // Sign the transaction
  const tx = new Tx(txObject)
  tx.sign(k1)

  const serializedTx = tx.serialize()
  const raw = '0x' + serializedTx.toString('hex')

  // Broadcast the transaction
  web3.eth.sendSignedTransaction(raw, (err, txHash) => {
    console.log('txHash:', txHash)
  })
})

The error thrown is as follows:

  UnhandledPromiseRejectionWarning: TypeError: Tx is not a constructor
      at GetTransactionCountMethod.web3.eth.getTransactionCount (C:\Users\Atul\Web3_code\send_transaction.js:22:14)
      at GetTransactionCountMethod._callee$ (C:\Users\Atul\node_modules\web3-core-method\dist\web3-core-method.cjs.js:126:22)
      at tryCatch (C:\Users\Atul\node_modules\regenerator-runtime\runtime.js:45:40)
      at Generator.invoke [as _invoke] (C:\Users\Atul\node_modules\regenerator-runtime\runtime.js:271:22)
      at Generator.prototype.(anonymous function) [as next] (C:\Users\Atul\node_modules\regenerator-runtime\runtime.js:97:21)
      at asyncGeneratorStep (C:\Users\Atul\node_modules@babel\runtime\helpers\asyncToGenerator.js:3:24)
      at _next (C:\Users\Atul\node_modules@babel\runtime\helpers\asyncToGenerator.js:25:9)
      at process._tickCallback (internal/process/next_tick.js:68:7) (node:10632) UnhandledPromiseRejectionWarning: Unhandled promise
  rejection. This error originated either by throwing inside of an async
  function without a catch block, or by rejecting a promise which was
  not handled with .catch(). (rejection id: 1) (node:10632) [DEP0018]
  DeprecationWarning: Unhandled promise rejections are deprecated. In
  the future, promise rejections that are not handled will terminate the
  Node.js process with a non-zero exit code.

I'm extremely new to this. Pls help.


texts:
Another "I accidentally sent x to y... question"

I sent some ETH from Coinbase to a VEN Wallet on hitbtc. I meant to send it to my ETH wallet on hitbtc so I could buy VEN. Coinbase is showing that the transaction was successful.

I've reached out to both services explaining what happened, and wondering what my recourse is. Several people have told me that I might be ok since VEN is an erc20 token.

Any idea what's going to happen? It's been about 30 minutes and nothing is showing up over on hitbtc.

https://www.etherchain.org/tx/3bfc8bcfda34841ba778eb20fa2a72389ba80fcd9d88538ed5c351f5f183622b


texts: Using a bash script containing truffle commands to connect with multiple network in order to send transactions

texts:
Context:

I have created a local Ethereum test net. I am using truffle to send transactions to EVM nodes. I have created a bash script that looks as follows (send_transactions.sh):

sudo truffle console  --network ethrpc1
exec ./batch.js
.exit
sudo truffle console  --network ethrpc2
exec ./batch.js
.exit
sudo truffle console  --network ethrpc3
exec ./batch.js
.exit
sudo truffle console  --network ethrpc4
.exit

ethrpc1, ethrpc2, ethrpc3, and ethrpc4 are my EVM nodes. The batch.js has the transactions that I send to each of these nodes.

Problem:

The above bash script stops working after the line "sudo truffle console  --network ethrpc1". It opens the truffle console and remains there without executing the rest of the commands in the bash script.

I have got this to work by typing these in my Linux command prompt manually but the shell script does not work. Is there a way to get the above commands to work using a bash script or is there an alternative method to automate sending transactions to multiple nodes without doing it manually?

Versions

I am using Ubuntu 18.04.3 LTS AWS EC2 instance

Truffle version: Truffle v5.1.28


texts: Is there a way to use the web3 "coder" module as a standalone?

texts:
I'm trying to use https://github.com/ethereum/web3.js/blob/master/lib/solidity/coder.js to easily encode/decode my data but i'm having a hardway figuring out how to use it.

Is it available as a function of web3 directly ?

Can someone explain me how to use it ?


texts: ELI18 - ELI21 How do applications running on Ethereum work? Where is the application data stored?

texts:
From my understanding there are applications running "on the Ethereum blockchain" and these applications are available through Mist.

What does it mean that the applications run on the Ethereum blockchain?
Where is the data for these applications stored? I understand that some data such as account balances for these applications may be stored on the blockchain, but what about the rest of the application?


texts: what are the diffrences between .call and .?

texts:
contract GatekeeperOne {

  address public entrant;

  modifier gateOne() {
    require(msg.sender != tx.origin);
    _;
  }

  modifier gateTwo() {
    require(msg.gas % 8191 == 0);
    _;
  }

  modifier gateThree(bytes8 _gateKey) {
    require(uint32(_gateKey) == uint16(_gateKey));
    require(uint32(_gateKey) != uint64(_gateKey));
    require(uint32(_gateKey) == uint16(tx.origin));
    _;
  }

  function enter(bytes8 _gateKey) public gateOne gateTwo gateThree(_gateKey) returns (bool) {
    entrant = tx.origin;
    return true;
  }
}

contract test{
GatekeeperOne public t;
function test()public payable{
    t = GatekeeperOne(0x5c3c1540dfcd795b0aca58a496e3c30fe2405b07);

}
function attack()public payable{
    t.call.gas(41171)(bytes4(keccak256("good(bytes8)")), 0x123);
}
function attack2()public payable{
    t.enter(0x123);
}
function()public payable{}

}

when I execute the attack() it will be sucessful. And attack2() will fail.
the error message:

transact to test.attack2 errored:

  VM error: revert. revert The transaction has been reverted to the
  initial state. Note: The constructor should be payable if you send
  value.    Debug the transaction to get more information.


texts:
Whenever i run truffle migrate for any contract i get the following error:

Error: Attempting to run transaction which calls a contract function, but recipient address 0xc3041510ef6e2d9f4352c974093dd9f92108067a is not a contract address
    at Object.InvalidResponse (/home/vinayak/.nvm/versions/node/v8.6.0/lib/node_modules/truffle/build/webpack:/~/web3/lib/web3/errors.js:38:1)
    at /home/vinayak/.nvm/versions/node/v8.6.0/lib/node_modules/truffle/build/webpack:/~/web3/lib/web3/requestmanager.js:86:1
    at /home/vinayak/.nvm/versions/node/v8.6.0/lib/node_modules/truffle/build/webpack:/~/truffle-provider/wrapper.js:134:1
    at XMLHttpRequest.request.onreadystatechange (/home/vinayak/.nvm/versions/node/v8.6.0/lib/node_modules/truffle/build/webpack:/~/web3/lib/web3/httpprovider.js:128:1)
    at XMLHttpRequestEventTarget.dispatchEvent (/home/vinayak/.nvm/versions/node/v8.6.0/lib/node_modules/truffle/build/webpack:/~/xhr2/lib/xhr2.js:64:1)
    at XMLHttpRequest._setReadyState (/home/vinayak/.nvm/versions/node/v8.6.0/lib/node_modules/truffle/build/webpack:/~/xhr2/lib/xhr2.js:354:1)
    at XMLHttpRequest._onHttpResponseEnd (/home/vinayak/.nvm/versions/node/v8.6.0/lib/node_modules/truffle/build/webpack:/~/xhr2/lib/xhr2.js:509:1)
    at IncomingMessage.<anonymous> (/home/vinayak/.nvm/versions/node/v8.6.0/lib/node_modules/truffle/build/webpack:/~/xhr2/lib/xhr2.js:469:1)
    at emitNone (events.js:110:20)
    at IncomingMessage.emit (events.js:207:7)
    at endReadableNT (_stream_readable.js:1059:12)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickCallback (internal/process/next_tick.js:180:9)

Contents of migration file:

1_inital_migration:

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

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

2_delpoy_contracts:

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

module.exports = function(deployer) {
  deployer.deploy(DappToken,1000000); // passing an arg to constructor
};

I have tried changing ports and even making a contract form scrath.