texts: I have some question about Smart Contract

texts:
Where is the Smart Contract Data stored?
How does it get activated, as every contract has a logical outcome?
What happens to the block or the transaction in which the smart contract has been concluded?
Linked to #1, how do we access the data in a smart contract?
On what grounds does more than one transactions become a part of a block?

Example: We have a salary slip tied up in a smart contract for you. Salary slips are confidential and can only be seen by the person whose that slip is.
Now if company generates a transaction with a smart contract, which should be view able only on the 3th of every month.

How will be the functional flow , and what does company have to give you to access your slip


texts: What’s the purpose of the following code ? Increase public storage usage?

texts:
I found the following code in this contract.

// `hat` address is unique root user (has every role) and the
// unique owner of role 0 (typically 'sys' or 'internal')
contract DSChief is DSRoles, DSChiefApprovals {

    function setOwner(address owner_) public {
        owner_;
        revert();
    }

    function setAuthority(DSAuthority authority_) public {
        authority_;
        revert();
    }

    function setRootUser(address who, bool enabled) public {
        who; enabled;
        revert();
    }
}

Am I missing something or the only purpose of lefting this in non testing contract is to increase transaction fees ?


texts: How do I run the Ethereum Wallet software on a private chain?

texts:
I have read this post over and over again, but I can't wrap my head around the answer.

I too have downloaded the Ethereum Wallet, but want to test some things separately from the main chain (I figured this is a must, as I don't have any ether, nor the CPU/GPU power to mine). So, I have also downloaded Command Line Tools (geth) and put geth.exe in C:\ (I'm on Windows 10). I execute the following as a simple test:

geth --datadir "C:\Test" --rcp

Which results in the Test dir being created and localhost:8545 outputting:

{
   id: null,
   jsonrpc: "2.0",
   error: {
       code: -32600,
       message: "Could not decode request"
   }
}

Ethereum Wallet won't run because it can't start a node (there's already one running). Furthermore, I have no idea how to use --ipcpath seeing as it is not in the flags list for geth. Moreover, I have no idea how/where to implement the genesis.json, which I read about everywhere.


texts: Why does Ethereum Wallet application delay its startup until fully synchronised?

texts:
When Ethereum Wallet is launched, it displays a splash screen with synchronisation progress and a link Launch Application to skip waiting for being fully synced:

What is the rationale here for keeping user from using the application by default?

Why does it require an action from user to proceed when not fully synced? Is there any risk or disadvantage to using the application when it has not been fully synced?


texts: (browserify) Error : Cannot find module 'web3/lib/solidity/coder.js'

texts:
When I use command browserify viz.js -o main.js to build this project, I receive following error message :

C:\Users\KX5710\Downloads\GUI_solarchain\solarchain-dashboard-master>browserify
viz.js -o main.js
Error: Cannot find module 'web3/lib/solidity/coder.js' from 'C:\Users\KX5710\Dow
nloads\GUI_solarchain\solarchain-dashboard-master'
    at C:\Users\KX5710\AppData\Roaming\npm\node_modules\browserify\node_modules\
browser-resolve\node_modules\resolve\lib\async.js:46:17
    at process (C:\Users\KX5710\AppData\Roaming\npm\node_modules\browserify\node
_modules\browser-resolve\node_modules\resolve\lib\async.js:173:43)
    at ondir (C:\Users\KX5710\AppData\Roaming\npm\node_modules\browserify\node_m
odules\browser-resolve\node_modules\resolve\lib\async.js:188:17)
    at load (C:\Users\KX5710\AppData\Roaming\npm\node_modules\browserify\node_mo
dules\browser-resolve\node_modules\resolve\lib\async.js:69:43)
    at onex (C:\Users\KX5710\AppData\Roaming\npm\node_modules\browserify\node_mo
dules\browser-resolve\node_modules\resolve\lib\async.js:92:31)
    at C:\Users\KX5710\AppData\Roaming\npm\node_modules\browserify\node_modules\
browser-resolve\node_modules\resolve\lib\async.js:22:47
    at FSReqWrap.oncomplete (fs.js:152:21)

Do i need to install some additional package ? or the problem is something else ?


texts:
I've tested with accounts created and unlocked in geth and my sample app works fine. I'm now going distributed with my accounts and have added eth-lightwallet and HookedWeb3Provider to put the account management on the user end.

I generate a couple of addresses and then try to create a contract. However I get the message 'account is locked'.

I've configured the hookedwebprovider as in the samples:

var web3Provider = new HookedWeb3Provider({
      host: "http://myaddress:8545",
      transaction_signer: keystore
    });
web3.setProvider(web3Provider);

Then try to use the generated addresses

 var account = keystore.getAddresses()[0];
 MyContract.new({from: account, gas: 10000000});

I had expected the error to be something like insufficent ether/gas, since the balances are 0. Do I need to call the new function in a different way or configure something else?


texts: how to get miner address from transaction hash

texts: In ethereum private blockchain i want to get the miner address from transaction hash. eth.getTransaction and eth.getTransactionReceipt are not giving miner details. is there any way to get miner address and total number of transaction validated by miner.


texts: Which is going to be the very last block of 2017?

texts:
I know that the last moment of the year depends in which time zone you are. But lets assume that we want the very last moment, so let's consider the last time zone (+12), I believe is Fiji or New Zealand.

Which is going to be the newest block in the ethereum blockchain at 11:59PM of December 31th 2017 in Fiji?

I know that it isn't that exact but is there a good approach of which block is going to be, considering there is a new block every 17 seconds aprox?


texts:
I sent 400 uni from brave wallet to uni metamask wallet, nearly 3 days ago it never showed up.
I'm very new to this and probably should have not done it but in my brave browser wallet i had 400 UNI as well as some smaller cheaper coins. I tried to send my UNI to my Metamask wallet. Not sure if i messed it up somehow here is the details: https://etherscan.io/tx/0x777441d3783417d0429c84522e374398c105bb31b5434383de27b1340bf4c134
Any help appreciated.


texts: How can I obtain my public key (using web3)

texts:
I know my Ethereum address, my Metamask wallet will give it to me, and I can run :

web3.eth.coinbase

But I want to know what my public key is.
Is there any way I can find that ?

(the reason I want to know a public key because I believe I need it to verify if a particular signed message was truely signed by that key)


texts: Common useful JavaScript snippets for geth

texts:
In geth you can loadscript any .js file.

I discovered this one on the wiki which I like a lot:

function checkAllBalances() {
  var i =0;
  eth.accounts.forEach( function(e){
    console.log("  eth.accounts["+i+"]: " +  e + " \tbalance: " + web3.fromWei(eth.getBalance(e), "ether") + " ether");
    i++;
  })
};

Are you using frequently other ones?
A kind of repository of 'classics' or 'must-have' would be a great resource to have.


texts: how to sign with the Ethereum private key and derive the the r, v, s it needs for verification

texts:
I know this kind of questions has been asked before, I want to know the detailed procedure to sign on msgs and derive the r, v, s(the command line), and the client and environment it needs to do the signing, thanks.
（I now use mist）


texts: How to catch Out of Gas exception in Oraclize Callback and display error on dapp front end

texts:
I have a smart contract inside which I have used Oraclize to get current time stamp. On few occasions the Oraclize callback fails due to out of Gas exception. How can one catch this failure and display error message on my dapp front end?

I tried below options :

Monitor an event to catch if Oraclize returns any value or not. In my case it returns the current time stamp and moves ahead to logic inside the callback function. So here I could not catch the exception.
Monitor a second event which is triggered when computations using the timestamp returned by Oraclize are complete. Here also I am unable to catch the exception as it runs out of gas before reaching the logic to trigger the success event.

As per my understanding the out of gas exception happens in between the above two events i.e. after sending value and before completing the processing it looses all the gas.

Please help to suggest what is the preferred way to handle this error and communicate to user on the frond end.


texts: Would the users still need to use Metamask or Mist if the dapp has a built in wallet?

texts: If a dapp has a built-in wallet, can the users intearact with the dapp without the need of Metamask or Mist?


texts: Read String as bytes (Oraclize callback)

texts:
I have an Oraclize call that returns the following (a string):

"00000000000000000000000000000000000000000000000000000000000003e8"

Now this is 1000 (bytes32 hex)

You can check here: https://www.rapidtables.com/convert/number/hex-to-decimal.html

Now the question is how do I read/convert this to 1000 in solidity?


texts:
Why don't these paper wallets show to me the Public key? Is it a secret?
Can I get a Public key with some wallets? Or I have to generate it with utils.
Where can I use the public key?
Do I need it at all?


texts: How to connect metamask private network node on VM

texts:
Hello i'm currently I have my chain running inside my virtual machine (with Ubuntu 16.04) and my PC (running Windows 10). NodeJS is running a server which i can access from http://192.168.0.108:3000/.  Metamask running on firefox inside the VM can actually connect to the network. Have tried what this post suggests( MetaMask and Access Ethereum Private Chain from other PC in the same network (for test) ) but had no luck so far.
This is my starting node commandgeth --datadir ~/eth-dev/ --identity 'nodo maquina local' --verbosity 4 --ipcdisable --rpc --port 30304 --rpccorsdomain "*" --nodiscover --syncmode "full" --networkid 7051872 --targetgaslimit 16233158 console


texts: Implementation Question for Licence Token

texts:
I am currently working on the idea of using token as licences for digital products. I am offering different documents and books in pdf format and want people to be able to buy them with ETH o.ä.. I could simply create a centralized database and keep track of every purchase but i am looking for a decentralized solution.
The idea is to create a token that represents each product. This would allow me to check your account for this token. If you own the correct token you may download the file otherwise you have to buy the token. So far so good.

I was thinking about two different implementations but have problems with both of them.
Mint a Token per document (through specific IDs) but make them non transferable.
This would allow user to forever own the licence to a document but restrict them from transferring this licence.
Create Token that can be transferred but have information about the original user address so that a mismatch of user address and the adress in the token would lead to an error when downloading the file. (Based on ERC-1155 https://eips.ethereum.org/EIPS/eip-1155)

The first solution seems more elegant to me as i don't have to store the information of the user address every time. But i am wondering about how make a token mintable to everyone? I only saw contracts where the ownership over the token contract has to be transferred beforehand.
To my understanding both contracts work if every document costs the same amount. The token contract would check for the money, id and potentially the user address and create a token with the corresponding id. All in one contract. But the whole concept falls apart once i would have different prices for different token. Now i need to check different prices for different IDs and i don't know how to do this without a centralized DB.

Do you guys have any ideas how to solve this issue? Or is there a better way of handling the problem?

Any input is greatly appreciated.


texts: Is the "-=value THEN +=value" order only important for transfer() or for transferFrom(), too?

texts:
Concerning the transfer() function of a StandardToken: Since DAO "white hack" I know that it's important for contract security to substract the value first and then add it to the recipients balance.
My assumption was that the same is true for transferFrom(). But as I compared a few different token contracts, I found there's no consistency:

HackerGold - first sub then add

FirstBlood – first add then sub

...

Which one is correct?


texts: How many transactions per second can we safely send?

texts:
We're working on a large-scale application that issues a lot of transactions and we are not sure what exact guarantees Ethereum/Geth gives us.

On Ropsten testnet, we try to issue 100 transactions at once but only a fraction get mined. It seems like some transactions get discarded by the transaction pool and therefore mess up subsequent transactions because of the transaction nonce.

I looked at the code here: https://github.com/ethereum/go-ethereum/blob/master/core/tx_pool.go#L80-L83

How is "non-executable transaction" defined? I assume this defines
transactions that can't be executed because of a too high nonce
If AccountSlots is set to 16 (and I assume the majority on the network
has set that), does that mean the 16 lowest transaction nonces will
go there?
Is the number of possible transactions per account in the
tx pool AccountSlots + AccountQueue or AccountQueue?
What if I try to send more than that? Will Ethereum silently drop the transaction? (as I assume that this is what is happening at the moment)?


texts: Using the same event name in different contracts

texts:
Suppose I have two different contracts, and I implement an event in each one of them.

If I use the same event name in both contracts, will it make it more difficult (or even impossible) to filter the events of a specific contract?

Should I (or would I be better off) using a unique name for each event?

For all it matters, I am using web3.js from the client side.

Thank you!


texts: How to listen for events at a specific contract

texts:
I am new to the world of web3 and trying to learn how to listen for events. I've been googling and reading for a while and can't seem to get something working. I'm able to subscribe to pendingTransactions and newBlockHeader but can't seem to get logs to work. Below is the closest I have gotten.

Right now the goal is to listen for logs at a specific address. Any help would be appreciated and an answer leading to a solution will garner an award.

const Web3 = require('web3');

const web3 = new Web3(new Web3.providers.WebsocketProvider('wss://mainnet.infura.io/ws'));
var subscription = web3.eth.subscribe('logs', {
    address: '0x1E0447b19BB6EcFdAe1e4AE1694b0C3659614e4e',
    fromBlock : 7500000,
}, function (error, result) {
    if (!error)
        console.log(result);
})
    .on("data", function (log) {
        console.log(log);
    })
    .on("changed", function (log) {
    });

// unsubscribes the subscription
subscription.unsubscribe(function (error, success) {
    if (success)
        console.log('Successfully unsubscribed!');
});

returns: (node:17575) UnhandledPromiseRejectionWarning: Error: Provider error: Subscription with ID null does not exist.


texts:
This accepted answer claims that one advantage of PoS vs PoW is that

some scalability problems can be addressed more easily with PoS

What are those scalability problems? What are the scalability benefits of PoS vs PoW?


texts: Error while connecting mist on private net

texts:
I want to connect the mist private net on ubuntu 16.04
step that i am doing to connect mist on private net are below:

create privatenet folder into ~.ethereum folder(which is into my Home folder).
also create one folder into name chaindata and make gensis.jason file into privatenet folder also.
run command geth --datadir ~/.ethereum/privatenet init ./privether/privategenesis.json
run command geth --datadir=. /.ethereum/privatenet/ --networkid 1234
then run command on other terminal geth attach ipc:.ethereum/privatenet/geth.ipc.
then open mist but it given error(attached screen shot)
                                                                             please help to get out this issue as I am new to ethereum mist setup


texts:
I have a question about the possibly strange behaviours of address:
0x0000000000000000000000000000000000000000

We know that:

ETH + ERC20 tokens sent there are burnt
Upon creation of a new smart contract, a transaction towards that address is to be issued
That there should be no owner of the private key of that address
It should not be an EOA (externally owned address)

Question:

How can tokens be sent OUT from this address as seen here:

https://etherscan.io/address/0x0000000000000000000000000000000000000000#tokentxns

How could it be that this address has mined several blocks and uncles

Thanks in advance


texts: How to get parameters of an object from array using loop

texts:
I am using a loop to retrieve an object from array. Then get its details and compare it with other string. But it gives error

  Type bytes32 is not implicitly convertible to expected type struct
  UserRecord.Service storage pointer.

contract UserRecord {
  address public owner;
  bytes32[] public Servicelist;

  constructor () public {
    owner = msg.sender;
    newService("1","Serviceone",msg.sender);
  }

  struct Service {
    address serviceowner;
    string servicename;
    bytes serviceid;
    bool isService;
  }

  mapping(bytes32 => Service) public servicestructs;

  function isService(bytes32 uid) public view returns(bool isIndeed) {
    return servicestructs[uid].isService;
  }

  function getServiceCount() public view returns(uint count) {
    return Servicelist.length;
  }

  function newService(bytes32 uid, string memory _servicename, address _serviceowner) public returns(bool success) {
    require(!isService(uid));
    servicestructs[uid].servicename = _servicename;
    servicestructs[uid].serviceowner = _serviceowner;
    servicestructs[uid].isService = true;
    Servicelist.push(uid);
    emit LognewService(owner, uid, _servicename, _serviceowner);
    return true;
  }

  function getService(string memory servicequery) public view returns(bool) {
    for(uint i=0;i<Servicelist.length;i++) {
      Service storage service=Servicelist[i];
      string memory service_name=Servicelist[i].servicename;
      if(keccak256(abi.encodePacked(service_name))==keccak256(abi.encodePacked(service_name))) {
        return service_name;
      }
    }
  }

  event LognewService(address sender, bytes32 hash, string servicename, address serviceowner);
}


texts: Truffle sendTransaction sending eth to contract address returns revert

texts:
I have a contract address not a deployed contract instance in which i want to send ETH to but it fails giving Error: VM Exception while processing transaction: revert

MyContract.deployed()
  .then(async instance => {
 ...
var send = await web3.eth.sendTransaction({
    from: account[0],
    to: contract_addr,
    value: weiSpend
  });
});

testRPC

 Transaction: 0xfe824090f7cc99d85041d4ad7dde7bf91f36587871546faf97ca33641ad08e73
  Gas usage: 21046
  Block Number: 27
  Block Time: Mon Jan 22 2018 11:49:03 GMT-0600 (CST)
  Runtime Error: revert


texts: Solidity Library call gives Member not found or not visible after argument-dependent lookup

texts:
Using Solidity 0.4.17, I have defined a simple library at ./StringUtils.sol

library StringUtils {
    function isEmptyString(string s) external pure returns (bool) {
        return (keccak256(s) == keccak256(''));
    }
}

Now I am trying to use it in a contract at ./PastryChef.sol

import './StringUtils.sol';

contract PastryChef {
    using StringUtils for StringUtils;

    string name;

    function PastryChef(string _name) public {
        require(!StringUtils.isEmptyString(_name)); // name must not be empty
        name = _name;
    }

}

I get the error

TypeError: Member "isEmptyString" not found or not visible after argument-dependent lookup in type(library StringUtils)
        require(!StringUtils.isEmptyString(_name)); // name must not be empty
                 ^-----------------------^

What am I doing wrong?


texts: How could I get public array from JavaScript?

texts:
I have an array in smart contract:

contract SuperContract {
    uint[] public SuperArrayForExample;

    function addItemToArray(uint item) payable {
       SuperArrayForExample.push(item);
    }
}

I try to get this array from JavaScript:

contract['SuperArrayForExample'](uint256).call().then(response => {
   console.log(response); // I would like to see my array here
});

I would like to see my array here but I get this error:

Uncaught (in promise) class org.tron.common.runtime.vm.program.Program$IllegalOperationException : Invalid operation code: opCode[fe];


texts: How to resend a transaction not recognized by the network?

texts:
I've sent a simple transaction (no smart contract invocation) while my geth node had no peers attached. It created the transaction fine and returned a transaction identifier.

Even with many nodes connected now, I cannot find this transaction on any block explorer. I presume this means it wasn't broadcasted?

How can I rebroadcast the transaction?


texts: POA ethereum Add Authority Account Contract

texts:
Can someone point me right tutorial to understand the following

1) Genesis configuration for POA with pre-fund account

2) How to add Authority account at run time means once the blockchain is up and running

3) Sample working contract for same where user can vote to add new authority account.


texts: Help me understand this sample code for new ERC20 token

texts:
This is my first question here so please bear with me.

I have deployed my first token on test network.
I was reading about how to improve Token contracts and stumbled upon this sample file.

This file looked very neatly written but at the same time raised some questions.

https://github.com/bitfwdcommunity/Tutorials/blob/master/Tutorial%201/tutorial1_contract.sol

Can someone please confirm me following: -

1)
These are functions to safely perform math operations, Right?

contract SafeMath { }

2)
What is the use of ApproveAndCallFallBack ?

contract ApproveAndCallFallBack {
    function receiveApproval(address from, uint256 tokens, address token, bytes data) public;
}

3)
What is this contract Owned ?
I dont get it.

contract Owned {
}

Please help. Thanks


texts:
I start truffle console and type Greeter.deployed().setGreeting("Hello world!");

I receive the following error:

TypeError: Greeter.deployed(...).setGreeting is not a function

How can I solve this issue? Hoping your answer！Like the following diagram：


texts: Prevent double withdrawal ERC20 API attack

texts:
How do I prevent against the double withdrawal attack described in ERC20 API: An Attack Vector on Approve/TransferFrom Methods and initially posted here?

An example of the attack:

  Alice allows Bob to transfer N of Alice's tokens (N>0)  by calling approve method on Token smart contract passing Bob's address and N as method arguments
  After some time, Alice decides to change from N to M (M>0) the number of Alice's tokens Bob is allowed to transfer, so she calls approve method again, this time passing Bob's address and M as method arguments
  Bob notices Alice's second transaction before it was mined and quickly sends another transaction that calls transferFrom method to transfer N Alice's tokens somewhere
  If Bob's transaction will be executed before Alice's transaction, then Bob will successfully transfer N Alice's tokens and will gain an ability to transfer another M tokens
  Before Alice noticed that something went wrong, Bob calls transferFrom method again, this time to transfer M Alice's tokens.

  So, Alice's attempt to change Bob's allowance from N to M (N>0 and M>0) made it possible for Bob to transfer N+M of Alice's tokens, while Alice never wanted to allow so many of her tokens to be transferred by Bob.


texts: Do nodes need to have static IP addresses to connect to a private blockchain?

texts:
A private blockchain on Ethereum:

When we want to add more than one nodes, e.g. two nodes A and B, to a private blockchain, we let node A add the other node: admin.addPeer() and node B call A. Both nodes know the other nodes via their IP address. But their IP address may not be static.

Question 1: Do the nodes need to have static IP addresses to connect to each other?

Also, here it's said: "If your peers are not on the local network, you need to know your external IP address (use a service) to construct the enode url"

Question 2: What service does it mean? In this case, do we need to have a static IP address?


texts: How does a program determine if the peer node is a bootnode or full node?

texts: Looking at the DEVp2p protocol, I see that a peer can return info on capabilities ETH or SHH . I do not see in the protocol docs what those mean. How does a client discover if the peer is only implementing RLPx / Kademlia discovery, rather than the full Ethereum protocol?


texts: Member "transfer" not found, solidity 0.5

texts:
Get the following error message, which I suspect has something to do with the solidity version 0.5, that I'm using?

Error message

  $ truffle test

  Using network 'development'.

  /contracts/DappTokenSale.sol:39:9: TypeError: Member "transfer" not found or not visible after argument-dependent lookup in address.
          admin.transfer

  Compilation failed. See above.

  Truffle v5.0.1 (core: 5.0.1)
  Node v11.6.0

Code

pragma solidity ^0.5;

import "./DappToken.sol";

contract DappTokenSale {
address admin;
DappToken public tokenContract;
uint256 public tokenPrice;
uint256 public tokensSold;

event Sell(address _buyer, uint256 _amount);

constructor (DappToken _tokenContract, uint256 _tokenPrice) public {
    admin = msg.sender;
    tokenContract = _tokenContract;
    tokenPrice = _tokenPrice;
}

function multiply(uint x, uint y) internal pure returns (uint z) {
    require(y == 0 || (z = x * y) / y == x);
}

function buyTokens(uint256 _numberOfTokens) public payable {
    require(msg.value == multiply(_numberOfTokens, tokenPrice));
    require(tokenContract.balanceOf(address(this)) >= _numberOfTokens);
    require(tokenContract.transfer(msg.sender, _numberOfTokens));

    tokensSold += _numberOfTokens;

    emit Sell(msg.sender, _numberOfTokens);
}

function endSale() public {
    require(msg.sender == admin);
    require(tokenContract.transfer(admin, tokenContract.balanceOf(address(this))));

    admin.transfer(address(this).balance);
}

}


texts: Encode raw transaction data for inner transaction data for transfer using erc223

texts:
How do I encode data for inner transaction call of ERC223Receiver contract after transferring erc223 tokens to it?

example:

Contract ERC223Receiver {
    function foo(uint256 a) {
        // some work
    }
}

Contract Other {
    function bar(address token, address receiver, uint256 amount, uint256 a) {
        bytes4 sig = bytes4(sha3("foo(uint256)"));

        bytes data = bytes(sig + a) // ????

        token.transfer(receiver, amount, data);
    }
}


texts: Correct way of sending Token via contract

texts:
[Sender] -> [My Contract] -> [ERC20 Contract]

The sender invokes my Contract, and my contract in turns will invoke ERC20 contract to Transfer token on behalf of the senders (using his msg.sender).

However, the ERC20 contracts Transfer() function msg.sender will become the My Contract's address instead of the Sender's address.

May I know what is the correct way for My Contract to Transfer a Token on behalf the Sender?


texts:
I have linux based miner with geth wallet.
I've backed up keyfile (starting with UTC ... ..... ) into my second computer based on Windows where I've sucessfully imported it into Geth keystore folder.

I've runned up console with command

“eth.getBalance(eth.coinbase)”

and it shows up 0.

The thing is that my account has already some Ether as I'm checking it on Etherscan.

Can you please explain me what's happening ?

Thank you!


texts: Check that the timestamp of the block is greater than that of the previous block and less than 2 hours into the future?

texts:
I am reading the White Paper of Ethereum. And at the Mining Section, I do not understand the this part "less than 2 hours into the future" of the following sentence:

  Check that the timestamp of the block is greater than that of the previous block and less than 2 hours into the future.

And also, there is also a note here I do not understand:

  2. Technically, the median of the 11 previous blocks.


texts: What is the purpose of setting web3.eth.Contract.defaultBlock?

texts:
In web3 object, the default value of web3.eth.Contract.defaultBlock is always "latest".
But what could be the case to modify defaultBlock value?
Thanks


texts: Can we send transactions to specific node?

texts: If we are run a full node on our server for mining purposes, then can we send transactions to our node for mining purposes in order to save our transaction fees?


texts: Smart Contract is not working on Geth private network, while it does work on Ganache as well as Remix

texts:
I've only begun working with geth from last week and have faced the quite a challenge. I've written a smart contract and it works on remix (JavaScript VM) but somehow it does not work on my geth private network.

I've tried to deploy the same smart contract on Ganache and it worked fine.

I really don't know whether my geth private network is not functioning properly or my smart contract is at fault here. Please help

Genesis.json

{
  "config": {
    "chainId": 111,
    "eip155Block": 0,
    "eip158Block": 0
  },
  "alloc"      : {},
  "coinbase"   : "0x1000000000000000000000000000000000000000",
  "difficulty" : "0x10000",
  "gasLimit"   : "9721975",
  "nonce"      : "0x0000000000000042",
  "mixhash"    : "0x0000000000000000000000000000000000000000000000000000000000000000",
  "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
  "timestamp"  : "0x00"
}

Geth initialization

geth --datadir ./node1 --keystore keystore init genesis.json

Geth console

geth --identity "1" --keystore keystore --datadir ./node1 --networkid 111 --port 30303 --nodiscover --rpc --rpcapi "db, personal, eth, web3, debug, miner, net, txpool" --rpccorsdomain="*" --rpcaddr="localhost" --rpcport 8545 --gasprice 20000000000 --allow-insecure-unlock console

Truffle configuration

module.exports = {
  networks: {
    development: {
      host: "127.0.0.1",
      port: 8545,
      network_id: "111",
      from: "0x2a223397b04891e552f540900bde25383f32f7c8"
    }
  }
};

Smart contract

pragma solidity ^0.5.8;

contract SendMessage {

    struct Message{
        uint ID;
        string text;
        address from;
        address to;
    }
    event countEvent(
        uint indexed messagesCount
    );

    mapping(address => bool) public senders;
    mapping(uint => Message) public messages;
    uint messagesCount;
    address public owner;

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

    function sendText (string memory _text, address _to) public {
        messagesCount++;
        messages[messagesCount] = Message(messagesCount, _text, msg.sender, _to);
        emit countEvent(messagesCount);

    }

    function getCount () public view returns(uint) {
        return messagesCount;
    }
}

When I deploy the smart contract on the geth private network, it gets deployed without any issues, and I can execute sendText function with with following command in truffle console.

let app = await SendMessage.deploed()
let accounts = await web3.eth.getAccounts()
app.sendText("1st", accounts[1], {from:accounts[0]})

Transaction is successfully mined on the blockchain, but transaction log is empty in the transaction receipt. Here is the transaction receipt.

Assuming from the empty log the function did not succeed and messagesCount did not increase, subsequently when I call getCount() function I get error.

Geth version: 1.9.3-stable
Go version: go1.12.9
Nodejs version: v10.16.0
Solidity version: 0.5.11
Web3js version: 1.2.1


texts:
That is, the address of the token used as collateral in the Synthetix ecosystem.

I found two addresses:

0xC011A72400E58ecD99Ee497CF89E3775d4bd732F
0xC011a73ee8576Fb46F5E1c5751cA3B9Fe0af2a6F

The former is used by MetaMask and Etherscan and has a logo, but the latter is used by Uniswap and is deployed more recently.


texts: Breaking one large contract to multiple smaller contracts

texts:
I'm building a project which has the following artifacts:

the complete code for Oraclize API, inline, (1329 lines of code
including comments and description)
SafeMath Library, inline, (114 lines of code)
a contract called Ownable which has codes to change owner, modifiers
related to owner etc. this contract is small (around 80 lines)
the main project contract which is large (around 1300 lines of code,
including comments and function description)

all these four artifacts are inline in the same file called ProjectName.sol.

I'm unable to deploy this project using truffle as I believe the size limit of the project has been exceeded (24576 bytes). Can you please tell me what would be the industry standard (best practice) to break this code into multiple contracts?


texts:
I used the command truffle unbox react to build a dapp. It is just the initial step of my dapp development. However, it sucks. It continually pops up

gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe` failed with exit code: 1

this error. I've already google this error. Therefore, I set my python default version at 2.7 and install visual studio 2015 and visual studio 2017. Also I've
reinstall node-gyp and npm to make sure if it is  the latest version. I've tried whatever I can google. PLEASE HELP!


texts: Is it possible to split single Solidity contract across multiple files?

texts:
My team is currently working on a single smart contract that contains multiple functions that share state. We are using Git, and are constantly facing merge conflicts. The best way to reduce conflicts is to split work across multiple files.

Is it possible to split Solidity contracts into multiple "parts" that compose functionality into the same contract? (possibly one function group per file)


texts: Metamask Cannot Open (loading white screen)

texts:
I just trying open metamask but it not opening, and displaying whitescreen
with below errors in console :

  Error :

MetamaskContentscript - lost connection to MetaMask Contentscript
 Forwarding MetamaskContentscript - lost connection to MetaMask Inpage
 MetamaskContentscript - lost connection to MetaMask Background
 MetamaskContentscript - lost connection to MetaMask PingPongStream

  Image  :

thanks for your help


texts:
I am trying to configure arbitrage bot:
https://github.com/makerdao/developerguides/blob/master/keepers/simple-arbitrage-keeper/simple-arbitrage-keeper.md#simple-arbitrage-keeper-guide
I followed tutorial and got an error:
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='https', port=443): Max retries exceeded with url: //93ad48d9e784fd857d160044772e35.eth.rpc.rivet.cloud/:8545 (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f7b9ef7cfd0>: Failed to establish a new connection: [Errno -2] Name or service not known',))

This is my .sh settings file:

#!/bin/bash
/home/user/simple-arbitrage-keeper/bin/simple-arbitrage-keeper \
 --rpc-host 'https://93ad48d884d857d160044772e35.eth.rpc.rivet.cloud/' \
 --eth-from '0xD63e5265f0033FA77a316516f768d26F7f879F6a' \
 --eth-key 'key_file=/home/user/.ethereum/keystore/UTC--2020-10-06T15-07-58.672992832Z--d63e5265ffa77a316516f768d26f7f879f6a' \
 --uniswap-entry-exchange '0x47D4Af3BBaEC0dE4dba5F44ae8Ed2761977D32d6' \
 --uniswap-arb-exchange '0x1D79BcC198281C5F9B52bf24F671437BaDd3a688' \
 --oasis-address '0x4A6bC4e803c62081ffEbCc8d227B5a87a58f1F8F' \
 --oasis-api-endpoint 'https://kovan-api.oasisdex.com' \
 --entry-token '0xC4375B7De8af5a38a93548eb8453a498222C4fF2' \
 --arb-token '0xd0A1E359811322d97991E03f863a0C30C2cF029C' \
 --arb-token-name 'WETH' \
 --min-profit 1 \
 --max-engagement 10 \

As far as I understand the problem is with rpc-host settings. What do I do?


texts: Power of signing transactions and what you can do with that

texts:
I have been playing around with state channels and am starting to see the power of signing information/transactions, but haven't got a completely clear idea of what I can do with them. I think I can do the following, and would really appreciate, clarification, extra thoughts, and where I am just plain ol' wrong!

  Signing a payment but not sending it to the blockchain, but instead sending it to someone else to then send to the blockchain.

The signed transaction acts like a cheque(GB)/check(US). I sign a payment, but instead of sending the data to the blockchain, can I send that to the person I owe money to, and they send it to the blockchain, and therefore they pay the transaction fee, a bit like how a state channel sends the signed message to the other party, without going via the blockchain at all.

  Signing a payment, but in doing so cancelling an old one.

Imagine I do the above, but then before the recipient of the signed transaction commits it to the blockchain, I owe them more money. So I sign a new transaction that is the total of the original + the new money I owe. Is there an implementation I can use to mean that the old transaction wouldn't work if they submit the new one (or vice versa?) - I'm vaguely thinking nonces/sequence numbers or something. I can't quite visualise it, but I know that with state channels for say a game of chess if I submit a move to the blockchain, I can't submit previous ones based on sequence number. What about future ones....? Any quirky approaches here?

  Paying the transaction fees on behalf of a signed transaction

If I sign a transaction but send it to someone else, rather than to the blockchain so they can submit it, who pays the transaction fee? The person who paid sent the transaction, or the person who signed the transaction?

  Signing a transaction to deploy a contract

Imagine I have a contract that hasn't been deployed to the blockchain. Someone else wants to submit it so that they are the contract owner. Can they sign a transaction that means that I can deploy that contract on their behalf? If so, whats the mechanism here? The benefit being they pay for the contract to be deployed, rather than me. Or is the only way, if I don't have their private key, for me to deploy it and transfer ownership to them?

  If I have money in my wallet, and I want to buy something on a smart contract on behalf of someone else, who has no money in their wallet, can they sign a transaction and send it to me, so that I can send it to the contract and pay the costs myself, but they will be registered on the blockchain as the payer. I realise this may not show up in the transaction as them being the person who paid, but from the perspective of the smart contract, lets say there is a payable function, I pay that function, but the function records within the contract their address (perhaps their address is in the data field of the transaction) - is there a standard approach to this?

Thanks!


texts: How to declare a storage variable in vyper?

texts:
I am trying to convert my solidity code into vyper but I can't find a way to declare a storage variable.

My solidity function was this:

struct Account {
uint256 balance; // Account's balance
uint256 timeLocked; // If not 0, then account will be allowed to withdraw
}
mapping (address => Account) public accounts;

function addBalance() public payable {
Account storage a = accounts[msg.sender];
a.balance = a.balance + msg.value;

}

How can I make ato become a storage variable ?

I have another question, how can I make a require statement like this ?

require(_operator != address(0));

Seems that address(0) doesn't exist in vyper as it throws me errors.


texts: Mining for 5 days at an avg of 19 Mh/s but not a single cent, is this normal?

texts:
Okay so i've been using ETHMiner and this cmd file to start it, and I've been mining for about 60-80 hours with and avg of 19 Mh/s and I havent recieved a single cent to my Jaxx wallet, is this normal?

Ive changed 0xMYWALLETID to my actual ID

setx GPU_FORCE_64BIT_PTR 0 setx GPU_MAX_HEAP_SIZE 100 setx GPU_USE_SYNC_OBJECTS 1 setx GPU_MAX_ALLOC_PERCENT 100 setx GPU_SINGLE_ALLOC_PERCENT 100

ethminer -F http://eth-eu1.nanopool.org:8888/0xMYWALLETID -G

@Pause

I've been meaning to move over to Claymore Miner because im using my gtx 970 and I was following this guide https://eth.nanopool.org/help


texts: The most cost effective way to perform an Airdrop of tokens

texts:
I am doing a project where I create a token and try to airdrop it to as many people as possible. The challenge is to figure out the most cost-effective way to do so.

I had two options:

Create a "Token Vault" type smart contract, send tokens to it and pass an array of addresses and balances to some function.
Just create a new function in my token code before deployment that will be similar to approve(), but has an array of addresses as input. And just let people perform transferFrom() afterward.

As you can tell, both of these options are quite similar and my main concern is that both of them require me to pass an array of addresses. As I understand, if I want to pass an array of 1000 addresses it will cost me 21000 gas + 1000 SSTORE operations (20000 gas id _spender is not in mapping) totaling at 20021000 gas (if it is indeed possible to pass 1000 at once and not in separate batches). Calculating the cost for this very moment gives us 0.02 ETH or 16.297$, but that is only because the price of gas is at 1 wei atm.

Well, imagine if I perform a successful Airdrop campaign to thousands of people and the network is going to be congested because of another CryptoKitties leaving us with an average price of gas between 20 and 30 wei for weeks. Yeah, the price of deploying such contract will skyrocket to around 0.5 ETH.

It is not a commercial project, so doing crowdsale (which would cost me very little compared to what I am planning to do) is out of the question. The main goal of the project is to make regular non-tech/crypto savvy people familiar with Ethereum platform and make them do simple stuff for the first time: like creating a wallet, buying ETH, interacting with smart contracts, etc...

You might ask, why in this case don't I create a mintable token that people can mint for themselves, effectively costing me 0 eth after I deploy my token contract? Well, I believe that in order to reach many people the token should have some form of hypothetical value, otherwise, nobody would go through the struggle of even setting up a wallet and loading it with ETH. And when tokens are freely mintable, even if there is a limit of tokens per address, it will not stop some people from abusing it by creating multiple accounts and accumulating large sums for themselves. In other words, I want to have an ability to regulate total supply, so that people are not able to abuse the Airdrop process and render the token worthless (which it is anyway, but at least it might have some speculative value that will motivate people to go through the whole process).

I believe that there should be a way to do this without expensive arrays of addresses. However, since I have zero to none programming experience, it is not so obvious. Maybe there is a way to use some unique codes that I can distribute between people, which they will have to enter in order to unlock their airdrop tokens? But I will have to do it in such a way that doesn't require me to pass an array of such codes to be remembered in the contract. And, for example, those codes will satisfy some mathematical function but would be super hard or impossible to generate for anyone but me.

I would appreciate your input guys! Thank you for reading and sorry for such a long post!

TLDR;

Looking the best cost-effective way of distributing tokens fairly without having to pass an array of addresses to the token contract.


texts:
I am having the following piece of code in my smart contract:

uint256 gasBefore = gasleft();
externalContract.call.gas(gasLimit)(abi.encodeWithSignature(
  "myFunction(uint256,uint256)", param1, param2
));
uint256 gasAfter = gasleft();
uint256 gasSpent = gasBefore.sub(gasAfter);

emit GasSpentEvent(gasLimit, gasSpent);

The gas needed to call myFunction is 60630. When I set gasLimit to 60630, then gasSpent == gasLimit.

However, if I set gasLimit to any lower value gasSpent != gasLimit. What's even more interesting the difference between gasSpent and gasLimit is different every time I change gasSpent:

gasLimit: 20000 -> 21145 :gasSpent (diff 1145)
gasLimit: 20010 -> 21154 :gasSpent (diff 1144)
gasLimit: 20020 -> 21164 :gasSpent (diff 1144)
gasLimit: 20100 -> 21243 :gasSpent (diff 1143)

Why gasSpent != gasLimit only for failed calls? Why the difference between gasLimit and gasSpent changes? Is there any reliable way to calculate the gas spent on call?


texts: I am working on a contract in which I have a requirement to convert an integer to hexadecimal number. Suppose I have a number 234 its hexadecimal format is EA so how would I perform this in solidity. Please, someone help me with this.


texts:
I have a functioning contract that uses Ether as payment for functions and pays out ether based on actions.   Is there any good documentation for converting it to use a given token?

For instance below, how would this work with tokens?

pragma solidity ^0.4.13;

contract Test{
  address public party1;
  address public party2;
  enum SState {zero,one,two,three}
  SState public currentState;

  modifier onlyState(SState expectedState) {require(expectedState == currentState);_;}
  function Test() {
      currentState = SState.zero;
  }
  function pay1() payable onlyState(SState.zero) {
    require(msg.value == 1000000000000000000);
    party1 = msg.sender;
    currentState = SState.one;
  }
   function pay2() payable onlyState(SState.one){
    require(msg.value == 1000000000000000000);
    party2 = msg.sender;
    currentState = SState.two;
  }

  function finish(bool _winner) onlyState(SState.two){
    currentState = SState.three;
    if (_winner){
      party1.send(this.balance);
    }
    else {
      party2.send(this.balance);
    }
  }

}


texts: Is it possible to take the gas cost off of the payable value?

texts:
If a contract is payable and requires some amount of Ether is it possible to take the gas cost out of the sent value instead of directly from the user. Although both these values are coming from the user I would want a user to only be charged the value they are trying to send.
Lets just say for example a lottery contract. Each user would pay, for the sake of the example, 1 Ether to enter the lottery. However I would want to take off of that 1 Ether the gas cost, adding only the difference to the lottery contract and having my user pay the exact amount they wished to pay.


texts: Error: invalid address during getBalance and send Raw Transaction

texts:
Im using web3.js to retrieve the balance for the main account on my geth server

I set:

  let provider = new web3.providers.HttpProvider(ethereumNode)
  web3.setProvider(provider)

  if (!web3.isConnected()) {
    console.error('Ethereum - no conection to RPC server')
  } else {
    // is connected
    console.log('Ethereum - connected to RPC server')
  }

web3.eth.defaultAccount = from // from is my account on geth

// When goes to this line I get  Error: invalid address
console.log("balance ", web3.eth.getBalance())

Besides this, I m trying to broadcast a raw transaction where it gets the same error

  Error: invalid address

however If I run the same raw transaction on https://ropsten.etherscan.io/pushTx it works fine.

any ideas what is happening? I have the feeling is a problem on my geth server.

error stack on getBalance()

 Error: invalid address
     at inputAddressFormatter (.../node_modules/web3/lib/web3/formatters.js:271:11)
    at .../node_modules/web3/lib/web3/method.js:89:28
    at Array.map (native)
    at Method.formatInput (.../node_modules/web3/lib/web3/method.js:88:32)
    at Method.toPayload (.../node_modules/web3/lib/web3/method.js:114:23)
    at Eth.send [as getBalance] (.../node_modules/web3/lib/web3/method.js:139:30)
    at .../server/src/batches/export2contract.js:80:40
    at writeContract (.../server/src/batches/export2contract.js:61:10)
    at .../server/src/batches/export2contract.js:190:5
    at Array.forEach (native)

Error stack on sendTransaction:

   Error: invalid address
    at inputAddressFormatter (.../node_modules/web3/lib/web3/formatters.js:271:11)
    at inputTransactionFormatter (.../node_modules/web3/lib/web3/formatters.js:97:20)
    at .../node_modules/web3/lib/web3/method.js:89:28
    at Array.map (native)
    at Method.formatInput (.../node_modules/web3/lib/web3/method.js:88:32)
    at Method.toPayload (.../node_modules/web3/lib/web3/method.js:114:23)
    at Eth.send [as sendTransaction] (.../node_modules/web3/lib/web3/method.js:139:30)
    at .../server/src/batches/export2contract.js:135:32
    at writeContract (.../server/src/batches/export2contract.js:61:10)
    at .../server/src/batches/export2contract.js:190:5


texts: Retrieve the status of a contract by its creator

texts: In a situation where there are multiple contracts stored in different blocks, is there any method to retrieve the status of a contract through its owner's address? (e.g. in my situation, each person registered in the blockchain will only have one contract.This contract will be registered with the public key of this person, i.e. the contract owner will be a public key that corresponds to a person.If I know this public key , can I retrieve the status of this contract?)


texts:
Would like to implement ERC 865 (pay transfer fees with token instead of eth) or similar functionality in my smart contract. Is ERC 865 safe and audited currently? If not, is there any implementation out there that is safe to use?

Have been searching few similar implementation online and it seems that all of them has security issue. Glad to know if anyone actually use it on mainnet.


texts:
I know this one has been asked many times before and I think I get it, but I just need a little more clarification.

At the moment, https://ethgasstation.info shows the following gas prices

Safe Low 1 gwei
Standard 5 gwei
Fast     8 gwei

So, I get that those are the recommended gas prices depending on how fast I want my transaction to be processed.

My question is regarding the gas limit.
On this post, Questions about some details on Ethereum transfers and Gwei it mentions that a simple transfer will always be 21,000 gas but then later says gas limit is  21,000 + additional gas needed by the contract.

All I want to do is move some ETH from my wallet to an exchange, so does a simple transfer need any additional gas or is the original statement that 21,000 is enough true?

Am I right in thinking that if I use a limit of 21,000 at a price of 1 gwei to move ETH from my wallet to an exchange, it should go through in around 30 minutes?

The thing that concerns me about the limit is, if I don't specify enough, the transaction won't complete and I'll just lose the gas I've paid.

Thanks for any advice you can give.


texts: How should I secure a private key in my dapp?

texts:
We are currently building an app that interacts with the blockchain. It needs to be able to make transactions on the blockchain on it's own - for instance to add addresses to a whitelist. This means that it needs to have access to a private key that lets it sign the transactions. What is the best practice to store that private key?

To clarify, I want to know how to secure the APP's private key - not the user's keys.


texts: Could somebody explain me what is the difference of msg.sender, spender, from, to, owner in ERC20?

texts:
I read ERC20 solidity code below.

https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/contracts/token/ERC20/ERC20.sol

Then, I couldn't understand what the terms of msg.sender, spender, from, to, owner  mean.

I guessed msg.sender equals from, spender equals to, and msg.sender equals owner.
But if this hypothesis is true, allowed[from][msg.sender] isn't well defined.

I searched deeply but I couldn't get any information mentioned about above.
Could anyone describe the definition and usage?


texts: How add payment method to a private blockchain

texts:
I have a question about private blokchain:

I like to develop an Dapp in my own private blockchain. but i like to add payment method : i means,  how users account pay (with stripe,..) and load his balance (our local ICO ) in our local private blockchain.

We don't like using the ethreum public blockchain, to save the transaction fees ( gas ).


texts:
Tired of getting outputs like

"Warning! Error encountered during contract execution [Out of gas]"

and having to specify gas limit on every smart contract call like

sc.endpoint(parameters, {gas:1000000});

I would like to know if there is any web3 command similar to

web3.eth.defaultAccount = "...";

capable of define a new limit to gas consumed on my next transactions.

Variable web3.eth.gasLimit seems not to exist...

Thx!


texts: Pull-based reward distribution (Rewards Compounding) among stakeholders according to their shares in staking

texts:
In a naive implementation, the staking contract would
push fractional payments to all the participants each time a
reward gets distributed. However, in such an implementation
the distribute function would take O(N) time to compute,
where N is the number of participants.
Is there a better solution?
I've been working on the fractional approach pegged on block number instead of time
Distribution of rewards among stakeholders iterating over an array of stakeholders is inefficient in terms of gas spending. Therefore to calculate the reward since the last reward calculation requires keeping the sum of rewards at block #X and total staked at block #X. Hence, on each reward addition, we need to keep an array of the sum of stakes at a specific block number. And the second array is for the sum of rewards at a specific block number.
It's becoming quite complicated. To keep it non-reentrant along with an ever-growing 2 array of sums.
Need some input on how to implement this on-chain


texts:
I have the following contract:

pragma solidity ^0.4.11;
contract TA2_Transfer {
    address public sender;
    address public receiver;
    uint public packageCount;
    address owner;
    bytes32 name;
    mapping (address => uint) public balances;
    event Transfer(address from, address to, uint objCount);

    function sendToReceiver(address sender, address receiver, uint objCount)
        payable
        returns(bool success)
    {
        balances[sender] -= objCount;
        balances[receiver] += objCount;
        Transfer(sender, receiver, objCount);
        return true;
    }
}
contract ShippingOrder{
    address public oOrigin;
    address public oShipper;
    address public oCarrier;
    address public oReceiver;
    mapping (address => uint) public obalances;
    event Bal (uint balance);
    function ShippingOrder() {
        obalances[tx.origin] = 200;
    }
    function getBalance(address sender) returns(uint) {
        Bal(obalances[sender]);
        return obalances[sender];
    }
    function sendOrder(address oOrigin, address oShipper, address oCarrier,  address oReceiver, uint oCount)
        payable
        returns(bool success)
    {
        TA2_Transfer t= new TA2_Transfer();
        Bal(1);
        if(!t.sendToReceiver(oOrigin, oCarrier, oCount)) throw;
        if(!t.sendToReceiver(oCarrier, oShipper, oCount)) throw;
        if(!t.sendToReceiver(oShipper, oReceiver, oCount)) throw;
        return true;
    }
}

I am pretty sure That runs in Remix without problems.

But my test script still reports 0 in the Receiver account:

var ShippingOrder = artifacts.require("./ShippingOrder.sol");
contract('ShippingOrder', function(accounts) {
var meta;
var instance;
var  xInt = 10;
var origin = accounts[0];
var shipper = accounts[1];
var carrier = accounts[2];
var receiver = accounts[3];
 it("should put 200 in the first account", function() {
    return ShippingOrder.deployed().then(function(instance) {
      return instance.getBalance.call(origin);
    }).then(function(balance) {
      console.log("Init Complete");
      assert.equal(balance.valueOf(), 200, "200 wasn't in the first account");
    });
  });
 it("should put 10 in the receiver account", function() {
    return ShippingOrder.deployed().then(function(instance) {
      meta = instance;
      //console.log(meta);
      return instance.sendOrder.call(origin, shipper, carrier, receiver, xInt);
    }).then(function(result) {
      console.log("Transfer Complete");
});
});
 it("should have 10 in the receiver account", function() {
    return ShippingOrder.deployed().then(function(instance) {
      meta = instance;
      return meta.getBalance.call(receiver);
    }).then(function(balance) {
      console.log("Receiver Balance: "+balance.valueOf());
      assert.equal(balance.valueOf(), 10, "10 wasn't in the receiver account");
    });
  });
});

1) Contract: ShippingOrder should have 10 in the receiver account:

AssertionError: 10 wasn't in the receiver account: expected '0' to equal 10

What am I missing?


texts:
If Alice and Bob open a state channel with each other, for example a payment channel, and the state is as follows:

Alice initial balance: 1ETH
Bob initial balance: 1ETH

Bob sends Alice 0.20ETH
Alice sends Bob 0.25ETH
Bob sends Alice 0.30ETH

Final state: Bob=0.75ETH , Alice=1.25ETH

And Alice attempts to finalize the channel and settle on the main chain, however Bob (a malicious actor) proposes an alternate finalization as follows:

Bob sends Alice 0.20ETH
Alice sends Bob 0.25ETH
Bob sends Alice 0.01ETH
Bob sends Alice 0.01ETH

Final state: Bob=1.03ETH , Alice=0.97ETH

How is the contract able to decide which is the malicious actor in this scenario?

The only solution I could think of is if Alice wishes to publish the state to the blockchain, the final signature must be from Bob and vice-versa, but I couldn't find much documentation on this problem so I'm not sure if that solution fails in certain scenarios or not.


texts: Best options to host an ethereum react dapp to a custom domain

texts:
I'm looking for best options to host an ethereum dapp created using react and drizzle, with the following requirements:

It needs to be hosted in a custom domain (.com / .net /  OR .io ) that I have purchased.
It contains both client side scripts (static pages) and server side scripts (which individually interact with the smart contract in the blockchain).
It should have good scalability and accessibility by users.
I have an old hosting space that i purchased long back in DreamHost and HostGator. is it possible to use that for dapp hosting? What web servers would i need to install in it (apache? php?) ?

I have heard about heroku, digitalOcean, google and aws... any specifics would be appreciated.


texts: Downloaded Wallet from Ethereum Site and sent money without realizing what I was doing. Help!

texts: I tried really hard to figure this out on my own, but I'm pretty out of my depth, and I feel like the things that I have found that could answer my questions assume I already know some stuff.  I'm fairly new to crypto, but I kept hearing everyone say to get your stuff off of the exchanges and into a wallet.  I got the wallet from the ethereum website, opened it up, saw an address, and sent my ETH there.  I can link the transaction if that's helpful.  I have been unable to sync since then.  I can get within 100ish blocks, but then it just stops.  I'm well past the block containing my transaction, but my wallet still reads as empty.  I see now that I'm supposed to have command line tools or something.  I don't know nearly as much about computers as my mom thinks I do, and I'm wondering what I can do to access my ETH.  Can anyone help me?


texts: Transaction failed etherscan, coins disappeared?

texts:
Okay, I have no idea what just happened, but I think I just lost like 50% of my coins.
I sent Link from my ledger to binance, and when I checked an hour later, it said failed both on my ledger app and on etherscan.
In this case, the coins should have been reverted, since there is no transaction of my coins anywhere it seems.
As you can see on the screenshot, the balance isn't the same, so I have no idea what just happened.
Here is the transaction history, and the transaction link of the failed one.
https://etherscan.io/tx/0x608835629e3260ed94191409d4fd1e17b9d7d34ebd9b4d65ce041cdecfcf42a8
https://etherscan.io/address/0x338f1f7092a9897d1402c57361224dba78e07344
https://imgur.com/a/vCfITbZ


texts:
I am aware that miner can have influence on block.timestamp

My question is, how to avoid this warning?


texts: What should I keep in mind when building Dapps?

texts:
I am your average developer who is excited about building Dapps. However, these seem different from a traditional program. So:

Are there things that are flat-out impossible? What's the closest I can get?
What things are a given/easy in traditional programming but must be thought through thoroughly when making Dapps


texts: Get array of structs by giving address as parameter

texts:
Here's my code:

contract company {

    struct contractDetails {
        string contractId;
        string companyA;
        string companyB;
        address A;
        address B;
        uint256 timestamp;
        string signHash;
        bool isSigned;
    }

    mapping (address => contractDetails) contractAddr;
    uint public counter = 0;

     function createContract(string memory _contractId, string memory _companyA, string memory _companyB, address _B) public {
        counter++;
        contractAddr[_B] = contractDetails(_contractId, _companyA, _companyB, msg.sender, _B, now, '', false);
    }

function getAllContracts(address _address) public view returns(contractDetails[] memory) {
        contractDetails[] memory y = new contractDetails[];
        for(uint i = 0; i < counter; i++) {
            y[i] = contractAddrArr[i];
        }
        return(y);
    }
}

I'm expecting the result as below:

address1 => [struct1, struct2, struct3......]

A function should return an array of structs by passing a user's address as a parameter.


texts:
I'm using the Ethereum Wallet.

When I click - File > Backup > Accounts, it does nothing.

Can't see the UTC keystore files in AppData\Roaming\Ethereum Wallet

What am I doing wrong?

I have 1 Ether

Is writing down your wallet address worth anything?


texts:
Is there a way to compare pointers in Solidity?

I have two local variables:

uint256[] memory a = new uint256[](256);
uint256[] memory b = a;

If I try a == b I get this compiler error:

  TypeError: Operator == not compatible with types uint256[] memory and uint256[] memory


texts: It is very annoying that the contract widgets keep moving around. Is there an option to disable it or have the order alphabetical?


texts:
Can some one kind enough to tell me what are the differences between the 2?

I found that SendTransactionAsync works most of the time, but I can't get the returns value from a contract function. :(

Sorry if you think that this is a very simple question, I did search in google, but can't find definite answer.


texts: Why can't I establish a socket connection with Infura? Project ID is correct, I triple checked

texts:
I want to subscribe and listen to events that involve funds moving to my wallet, however I for some reason am not able to establish a socket connection to an Infura node.
First I npm init and npm web3.
The code:
const Web3 = require('web3');

class TransactionChecker {
    web3;
    web3ws;
    account;
    subscription;

    constructor(projectId, account) {
        web3ws = new Web3.providers.WebsocketProvider('wss://kovan.infura.io/ws/v3/' + projectId);
        web3 = new Web3.providers.HttpProvider('https://kovan.infura.io/v3/' + projectId);
        account = account.toLowerCase();
    }

    subscribe(topic) {
        this.subscription = web3ws.eth.subscribe(topic, (err, res) => {
            if (err) console.error(err);
        });
    }

    watchTransactions() {
        console.log('Watching all pending transactions...');
        this.subscription.on('data', (txHash) => {
            setTimeout(async () => {
                try {
                    let tx = await this.web3.eth.getTransaction(txHash);
                    if (tx != null) {
                        if (this.account == tx.to.toLowerCase()) {
                            console.log({address: tx.from, value: this.web3.utils.fromWei(tx.value, 'ether'), timestamp: new Date()});
                        }
                    }
                } catch (err) {
                    console.error(err);
                }
            }, 60000)
        });
    }
}

let txChecker = new TransactionChecker('projectId', 'address');
txChecker.subscribe('pendingTransactions');
txChecker.watchTransactions();

Gives me the following err: 'failed to create stateful backend, closing connection: websocket: bad handshake'
URLs are all good, why the error?


texts: Possible to make a REST call within geth console?

texts:
I want to listen to events on a contract and then send them to a rest endpoint.

Is it possible to make a REST call within the geth console?
Alternatively, if I have a node application and I load web3, how can I connect to the testnet?


texts: Calling a write function of a contract will deploy a new contract

texts:
I'm calling a function that will write information to contract, and MetaMask will list it as a 'Contract Deployment'. It is on the Rinkeby testnet. But if I run it locally using Truffle/Ganache, it will list it as a 'Contract Call', as opposed to a 'Contract Creation'.

Here is my code:

this.contract = new web3.eth.Contract(ABI, contractAddress)

let accounts = web3.eth.getAccounts()
...
let contractFunctionData = this.contract.methods.contractFunction(params).encodeABI()
web3.eth.sendTransaction({
  from: accounts[0],
  data: contractFunctionData
}, function(err, result) {
  if(!err)
    console.log(result)
})

when it logs result it returns the address of the new contract created.

This only happens with write functions. Read functions work as expected and return the right output.


texts: Can I automatically transfer Ether to a Bankaccount?

texts: I'm interested if it's possible to transfer Ether automatically (with conversion to a fiat currency) to a bankaccount without user interaction. For example with a SEPA transfer.


texts: Error when calling a get function from a deployed contract instance

texts:
I have developed a EnergyExchange DApp in the Ganache local network with React that consist of one main contract "EnergyExchange". This main contract has a function to deploy new Agent contracts.
So what I do is to store the deployed agents contracts in a mapping so later on when I want to interact with them I call the next function:
let contractInstance = await this.getAgentInstance();

That function returns the specific agent instance associated to the account is being used in the browser with metamask. See below the console.log of the instance:

As you can see, the getAgentInstance() function is returning the desired output though with some errors.(Any idea of why?)
But I was not worried about the error till something else happened. After I retrieve the instance of the Agent contract associated to the account I am using in Metamask, I use it to interact with the contract. i.e next function modifies the EnergyExchange main contract data:
async agentCancelSellOffer(){

  let contractInstance = await this.getAgentInstance();

  await contractInstance.cancelAddedSellOrder(this.state.inputCancelSellOrderId,{from:this.state.account});

}

And that function is executed fine. See also another function that is executed fine after retrieving the agent instance:
async agentAddOffer(){

  let contractInstance = await this.getAgentInstance();

  await contractInstance.addSellOrder(this.state.inputUnitsOfEnergy,this.state.inputPricePerUnit,{from:this.state.account});

}

The problem comes when I add into the logic a get function:
async agentGetDetails(){

  let contractInstance = await this.getAgentInstance();
  console.log(contractInstance);
  let details = await contractInstance.getAgentDetails({from:this.state.account});

  console.log('function get agentdetails executed');

The App crashes again after the next step:
let details = await contractInstance.getAgentDetails({from:this.state.account});

The getAgentDetails function from the AgentContract is detailed next:
 function getAgentDetails() public view isOwner returns(address,uint,uint,uint){
    return (agentAddress,agentID,agentCreationDate,agentAvailableEnergyToSell);

}

The error is what follows:

Any ideas of what I am doing wrong?
Thanks,


texts: What am I doing wrong with airdrop function?

texts:
I am trying to move some tokens from my erc20 token to my second account. I am using myetherwallet to test this:

ERC20Interface has transfer function only.

    ERC20Interface token;
    constructor(address _token) public {
        token = ERC20Interface(_token);
    }

As I understand I pass contract token address through constructor which is here:
https://rinkeby.etherscan.io/address/0x8966504a3b07e2cecd4f4bbb3d51566c7127b156

I then use function(i am doing transactions with an account which was initially assigned tokens so I have erc20 tokens):

function drop(address[] recipients, uint256[] values) public {
    for (uint256 i = 0; i < recipients.length; i++) {
        token.transfer(recipients[i], values[i]);

        emit DropedFun(address(this), recipients[i], values[i]);
    }
}

I am getting failed transaction:
https://rinkeby.etherscan.io/tx/0x4dcb95d87feed1f62cd50fe3921b5683878f718bc17dddf0150b9ba1a94e3059

Do I have to use transferFrom and put address which holds erc20 tokens, or should i transfer erc20 token to the address to be able to use .transfer function? If that's the case, how can I transfer erc20 token to contract?


texts: Can anyone please help me how can I start with blockchain testing,Deploy application and testing app

texts: I am completely new to blockchain testing.Can someone please help me with how can I start with blockchain testing and procedure from where I should start and material for the same if possible.


texts: Gas cost tests: Sending a transaction to a new address is more expensive?

texts:
A friend and I were thinking about transaction costs, is there any attached cost to send a transfer to a new address that has not been stored on chain before? So we started digging.

First off we called transfer to a new address and another one that has been used before, as expected the cost was 21000 for both of them.

New address: https://ropsten.etherscan.io/tx/0xec05af75ec938aa1cc78612b13d8d2e3c8f4212f60173161450297c9a25ea5a3

Miner (used before) address:
https://ropsten.etherscan.io/tx/0x7fe1c8c699901923d89e07a9b66e7d952c67064bcc9d86bf84bad07cac2391b1

Then we tried to made the transfer from an SC, this is the function we are using:

function test (address receiver) public payable {
        receiver.transfer(msg.value);
}

Simple enough, we started testing, called the function to a new address:

https://ropsten.etherscan.io/tx/0x38dabd569350fa985e11f892f7175ad09a32a0c067b993f68152f34d7ca4dcb3

First surprising thing was the cost to execute this function, was 55356 gas, much higher then the 21000 we saw before, we called it again:

https://ropsten.etherscan.io/tx/0xa2d23ea51102cc98f92b6ef89ed452a5be0e0ebbc26c136fc43f9a5a67a99a52

To our surprise, now gas costs were 30356 much less than before, why??

We tried to call the function on a used address (that should be already stored on chain) to see if sending to a new address was the differential factor, we did it twice:

https://ropsten.etherscan.io/tx/0xf9eb2e6536db2ec933ac21fb5bd8c422b6ae3b811f4bd72be4a55e02a6aec227

https://ropsten.etherscan.io/tx/0x4ef30764af81df4dc0dcc98bd4db5424c0c2bea99257df829b1c347a8764048f

And it costed 30356 in both.

Why does this happen, why sending ether to a new address from a SC costs over 50% more than sending to a used address?


texts: TypeError: Wrong argument count for function call: 2 arguments given but expected 1. Use abi.encodePacked

texts:
I was playing with this post code example:

function random() private view returns (uint8) {
       return uint8(uint256(keccak256(block.timestamp, block.difficulty))%251);
   }

But I'm always getting this error:

TypeError: Wrong argument count for function call: 2 arguments given but expected 1. This function requires a single bytes argument. Use abi.encodePacked

Any ideas? Thanks in advance. I don't find too much info about this issue.


texts: Public variable getter shows as transaction in Remix

texts:
As of Solidity 0.6.0+  compiler, my remix shows getter functions, built by public variables, as transactions and, therefore, do not return the value. I searched the solidity 0.6.0 breaking changes but I didn't find any explanation to this. What am I missing?

Example on solidity pragma <=0.5.16:

Example on solidity pragma >=0.6.0:


texts: solidity - How to detect an ERC token has just transferred money to my contract

texts:
I am developing an application that automatically converts eth, usdt ... to my token when they transfer money to my contract address.
With eth, I can do it, but how to detect other erc tokens, including my token transferred to the contract address.
I have read through some articles, describing the use of approve and then transferFrom. But this will cause the transferor to pay for 2 times . Are there any functions similar to payable of eth for tokens only?


texts:
In a custom fork of Ethereum my team is developing, we need to read a new config parameter from genesis block. At https://github.com/ethereum/go-ethereum/blob/master/cmd/evm/runner.go#L100 the code line:

gen := readGenesis(ctx.GlobalString(GenesisFlag.Name))

is supposed to read a config parameter from genesis block, right?

But what is ctx?, how to specify the flag name to GlobalString?

What goLang code would we need to read a given parameter, such as MyParameter from genesis block?

Is there any documentation about the go-ethereum code? Who did develop this code? Can I talk to him/her? Thx!


texts: Is it worth to create a gamification system using the Ethereum platform?

texts:
Sorry if this is a dumb question but I'm a newbie regarding the blockchain.

Currently, I have a centralized database to manage a gamification system (handling badges, points, votes, reputation, etc.). However, I'd like to decentralize it and I thought about using the Ethereum platform. So, I have two questions:

Is it possible to convert a centralized database into one based on the blockchain?
Is it financially viable? I mean, I don't fully get how this works. We have to pay every contract, right? Does that mean I'd pay for every new user or for every action made by users (e.g. every time their badges/reputation/etc. are updated)?

If the latter, it seems to be that the costs would be pretty high as the number of transactions would be huge. I'd appreciate if someone could clarify those points for me. Thanks!


texts:
assume that I have a private smart contract between peers A and B using quorum blockchain. Then, the variables of the smart contract will be placed in the private state.

My question is:

Can I make an API that enables to read some variables from the private state and returns a result?


texts: When bidding via the ens registrar page, one has to wait until the dictionary loaded before the "bid" button can be used. What is this dictionary and what does it do? Why is it possible to bid after it loaded only?


texts: Geth RPC running but cannot connect in Web3 nodejs

texts:
Wracking my brains here, geth is running the RPC as expected but I can't connect to it with web3 I'm running like so:

geth --rpc --rpccorsdomain "*" --rpcapi "eth,web3"

I'm running this in screen and see in the terminal it starts running the RPC API and then continues to sync the blockchain.

I have confirmed the API is running:

curl -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","method":"web3_clientVersion","params":[],"id":67}' http://localhost:8545

Which returns as expected:

{"jsonrpc":"2.0","id":67,"result":"Geth/v1.7.3-stable-4bb3c89d/linux-amd64/go1.9"}

I'm running nodejs v6.12.3 and npm install web3 this morning. The nodejs script I'm trying is:

#!/usr/bin/nodejs

var Web3 = require('web3');
var web3 = new Web3(); // returns as expected

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

var coinbase = web3.eth.coinbase;
console.log(coinbase); // undefined

I noticed that after running setProvider inspecting the web3 object I see:

_provider: HttpProvider { host: 'http://localhost:8545', timeout: 0, connected: false },

I've tried a number of other web3.eth API's but no luck. How can I get it connected? Have I fundamentally misunderstood something here?


texts:
I noticed on the official docs the networks are
Mainnet
Kovan
Rinkeby
Are there Chainlink Contacts / Nodes for Ropsten?


texts: Are there well-solved and simple storage patterns for Solidity?

texts:
Simple and appropriate data organization can challenge Solidity newcomers. It  wants us to organize everything in ways many of us aren’t accustomed to.

Are there well-solved general patterns for routine on-chain data organization?


texts: How/when to use the system-level variables in building contracts

texts:
I am a newbie to this field and currently learning to write some smart contract programs.

I am writing to inquire the best practice to use those system-level variables, such as BLOCKHASH, TIMESTAMP, COINBASE DIFFICULTY, and GASLIMIT when writing my contract.

I got the impression from the best practice manual that we should try to avoid using such variables, since they may be manipulated by malicious miners. But then in which situation do we need this? Could anyone shed some lights on a "legit" and "secure" usage of such variables? Thanks!


texts: Gas Costs - Reading Data - Is this Free?

texts:
I have conflicting information about this. I thought reading the blockchain was free but writing was at a cost.

Now someone says to me that executing any contract even just reading data has a gas cost.

I saw a discussion here - https://www.reddit.com/r/ethereum/comments/49t2jc/get_data_from_the_blockchain_without_using_gas/

Has anyone the real classification about this?


texts: Warning Message Relating To Gas and Infinite Loop

texts:
I have the following function that keeps getting a warning relating to high gas costs. Im assuming that it because Im using

  string & uint

but I may be wrong.  I looking for a bit of advice on how to structure this to reduce the possible gas costs, it will only ever be me running this particular function.

function AddNewLand(string _geoPoint1, string _geoPoint2, string _geoPoint3, string _geoPoint4, uint _totalinterest, uint _purchasePrice) public {

        if(ownerAddress == msg.sender){

            Land memory _land = Land({
                geoPoint1: _geoPoint1,
                geoPoint2: _geoPoint2,
                geoPoint3: _geoPoint3,
                geoPoint4: _geoPoint4,
                creationTime: uint64(now),
                totalInterest: _totalinterest,
                remainingInterest: _totalinterest,
                purchasePrice: 1000
            });

            uint256 landID = landRegister.push(_land) - 1;

            newLandAdded(landID);

        }else {

            error("Only the contract owner can add a new  of land.");

        }

    }

This is the message I am getting


texts: Most efficient way to do weighted pseudo randomness in Solidity?

texts:
Example I have this array ['a', 10, 'b', 1]

I need to get result 'a' 10x more time than result 'b', randomly.

What's the most efficient way to do this in solidity?

In javascript I was creating an array like this ['a','a','a','a','a','a','a','a','a','a','b']

An then picking a random index using Math.random()

Should I use the same approach? Would that cost too much gas?

It is expected that there could be up to 1000+ items in the array if I use this method.

Note that I wouldn't need secure randomness, just pseudo randomness would be fine.


texts: Can anyone explain what's the difference between mist/geth/parity in simple terms?

texts: What's the difference between geth/mist/parity?


texts: Deploy contract didnt resolve the promise

texts:
im facing a problem deploying a simple smart contract.

When i use ganacha-cli, the program enter in a loop of confimation event, counting from 1.
Thats the first problem.

Output:

Account: 0xd5f75a4F58da4dF050F84dedF07d24f7bf388F8F
trans hash: 0x1ab65a58debce4859a7df358ba54653fe0727b25f9d483622ab412ea7c49a56d
receipt: [object Object]
Contract address: 0xd2039ADAE2a61fADd65C4bec6a7791b2B6e56d08
confirmation: 1
confirmation: 2
confirmation: 3
confirmation: 4
confirmation: 5
...

And when i use a blockchain runing with geth in a server, the send method never is resolved. Only transaction hash is fired, and the contract is created in the blockchain. The second and main problem.

Output:

Account: 0xb5cF1ee3481B45d1A1cB939921f3f6E3f0C97f80
trans hash: 0x387a881262fbfee430bf761724bb5e21706fc2c76bb86dfd69aff526c46b985f

Code (web3 version 1.2):

var Web3 = require('web3');

var web3 = new Web3(new Web3.providers.HttpProvider('http://XXX.XXX.XXX.XXX:PPPP'));

var account = '0xb5cF1ee3481B45d1A1cB939921f3f6E3f0C97f80'

console.log('Account: ' + account);

web3.eth.personal.unlockAccount(account, "dos", 50000)

const deployedContract = new web3.eth.Contract([{"constant":true,"inputs":[],"name":"displayMessage","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"displayMessagex","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"}]);

deployedContract.deploy({
    data: '0x6060604052341561000f57600080fd5b6101ad8061001e6000396000f30060606040526004361061004b5763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416632d59dc128114610050578063910dc524146100da575b600080fd5b341561005b57600080fd5b6100636100ed565b60405160208082528190810183818151815260200191508051906020019080838360005b8381101561009f578082015183820152602001610087565b50505050905090810190601f1680156100cc5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34156100e557600080fd5b61006361012e565b6100f561016f565b60408051908101604052601281527f5768616c652068656c6c6f2074686572652100000000000000000000000000006020820152905090565b61013661016f565b60408051908101604052601781527f5768616c652068656c6c6f2074686572655858585858210000000000000000006020820152905090565b602060405190810160405260008152905600a165627a7a723058208eeb846120df236de217b296df57febcc6f992caf709d5cb6d4637c86b9427a40029'
}).send({
    from: account,
    gas: 10000000
})
.once('confirmation', function(confirmationNumber, receipt){
    console.log('confirmation: ' + confirmationNumber)
})
.on('transactionHash', function(hash){
    console.log('trans hash: ' + hash)
})
.on('error', function(error){
    console.log('error: ' + error)
})
.on('receipt', function(receipt){
    console.log('receipt: ' + receipt.toString())
})
.then(function(contract) {
    console.log('Contract address: ' + contract.options.address);
})
.catch(function(error) {
    console.log(error);
})

Geth command:

geth --port 3000 --networkid 87936 --nodiscover --datadir=. --maxpeers=0  --rpc --rpcport 8543 --rpcaddr 0.0.0.0 --rpccorsdomain "*" --rpcapi "eth,net,web3,personal,miner" --allow-insecure-unlock

Thanks!

After start mining the main problem convert in the first problem (is an advance), changed the on('confirmation') to once('confirmation') the output now is:

Account: 0xb5cF1ee3481B45d1A1cB939921f3f6E3f0C97f80
trans hash: 0xc5a2dc489815c205a53658bf5ebcde95593e83da4ead07355fcae4d722636c12
confirmation: 0
receipt: [object Object]
Contract address: 0x6b4A76Ab26e487Fdc502779Abc438d0cF59299bc


texts: If I get a full hash from a submitted tx, doesn't that mean the transaction is good?

texts:
I am running a geth full node on Rinkeby and testing ERC20 transactions. Recently I submitted two transactions and received transaction hashes for each of them, so I assumed I was good. But later on when looking at the geth log, I realized that both transactions failed because I didn't give enough gas.

Here is a gist of the transaction log snippet:

https://gist.github.com/gojun077/276e342d0c17422816d28466d40aad11

My program logic assumes that receiving a full hash for a tx submission means that the tx was good. But as you can see from the geth log, at 08:30:14 I got a full hash but 1 second later at 08:30:15 the announcement was discarded by a Peer and the EVM returns err="out of gas".

The second transaction gets a full hash at 08:30:15 but it errors out 2 seconds later at 08:30:17 and doesn't make it into the block.

I then tried to search for these tx hashes but they were nowhere to be found, both locally and on Etherscan. Is this normal behavior? Is there a way to detect "out of gas" transactions programmatically, i.e. without tailing logs?


texts: `vendor/` sub-directory relationship to 3rd party dependencies

texts:
In the -go-ethereum client directory I've run the command find . -name \*.md -print looking for README.md files. The output is as follows:

    ./.github/CONTRIBUTING.md
    ./.github/ISSUE_TEMPLATE.md
    ./build/ci-notes.md
    ./contracts/ens/README.md
    ./crypto/secp256k1/libsecp256k1/README.md
    ./log/README.md
    ./log/README_ETHEREUM.md
    ./README.md
    ./swarm/dev/README.md
    ./vendor/bazil.org/fuse/README.md
    ./vendor/github.com/aristanetworks/goarista/README.md
    ./vendor/github.com/Azure/azure-sdk-for-go/CHANGELOG.md
    ./vendor/github.com/Azure/azure-sdk-for-go/README.md
    ./vendor/github.com/Azure/azure-storage-go/README.md
    ./vendor/github.com/btcsuite/btcd/btcec/README.md
    ./vendor/github.com/cespare/cp/README.md
    ./vendor/github.com/davecgh/go-spew/README.md
    ./vendor/github.com/dgrijalva/jwt-go/MIGRATION_GUIDE.md
    ./vendor/github.com/dgrijalva/jwt-go/README.md
    ./vendor/github.com/dgrijalva/jwt-go/VERSION_HISTORY.md
    ./vendor/github.com/docker/docker/pkg/reexec/README.md
    ./vendor/github.com/edsrzf/mmap-go/README.md
    ./vendor/github.com/fatih/color/LICENSE.md
    ./vendor/github.com/fatih/color/README.md
    ./vendor/github.com/gizak/termui/README.md
    ./vendor/github.com/go-stack/stack/LICENSE.md
    ./vendor/github.com/go-stack/stack/README.md
    ./vendor/github.com/hashicorp/golang-lru/README.md
    ./vendor/github.com/huin/goupnp/README.md
    ./vendor/github.com/jackpal/go-nat-pmp/README.md
    ./vendor/github.com/karalabe/hid/LICENSE.md
    ./vendor/github.com/karalabe/hid/README.md
    ./vendor/github.com/maruel/panicparse/README.md
    ./vendor/github.com/mattn/go-colorable/README.md
    ./vendor/github.com/mattn/go-isatty/README.md
    ./vendor/github.com/mitchellh/go-wordwrap/LICENSE.md
    ./vendor/github.com/mitchellh/go-wordwrap/README.md
    ./vendor/github.com/naoina/go-stringutil/README.md
    ./vendor/github.com/naoina/toml/README.md
    ./vendor/github.com/nsf/termbox-go/README.md
    ./vendor/github.com/olekukonko/tablewriter/LICENCE.md
    ./vendor/github.com/olekukonko/tablewriter/README.md
    ./vendor/github.com/pborman/uuid/CONTRIBUTING.md
    ./vendor/github.com/pborman/uuid/README.md
    ./vendor/github.com/peterh/liner/README.md
    ./vendor/github.com/rcrowley/go-metrics/memory.md
    ./vendor/github.com/rcrowley/go-metrics/README.md
    ./vendor/github.com/rjeczalik/notify/README.md
    ./vendor/github.com/rs/cors/README.md
    ./vendor/github.com/rs/xhandler/README.md
    ./vendor/github.com/syndtr/goleveldb/README.md
    ./vendor/golang.org/x/crypto/CONTRIBUTING.md
    ./vendor/golang.org/x/net/CONTRIBUTING.md
    ./vendor/golang.org/x/sys/CONTRIBUTING.md
    ./vendor/golang.org/x/text/CONTRIBUTING.md
    ./vendor/golang.org/x/tools/CONTRIBUTING.md
    ./vendor/gopkg.in/check.v1/README.md
    ./vendor/gopkg.in/fatih/set.v0/LICENSE.md
    ./vendor/gopkg.in/fatih/set.v0/README.md
    ./vendor/gopkg.in/karalabe/cookiejar.v2/README.md
    ./vendor/gopkg.in/natefinch/npipe.v2/README.md
    ./vendor/gopkg.in/sourcemap.v1/README.md
    ./vendor/gopkg.in/urfave/cli.v1/CHANGELOG.md
    ./vendor/gopkg.in/urfave/cli.v1/README.md

Based on this it looks like all the "3rd party" dependencies are located in the vendor/ directory. Is that the case? Why is this directory called as vendor?


texts: Transaction has been reverted by the EVM - How to deduce the revert reason in this case?

texts:
I get this error when I call a function that changes the state of the smart contract from the frontend:
Error: Transaction has been reverted by the EVM:
{
  "blockHash": "0xf722c45e7a8d53ab72775ecab1f3414725f41e8587166a1848c5a4fb29566629",
  "blockNumber": 9527889,
  "contractAddress": null,
  "cumulativeGasUsed": 1931716,
  "from": "0x334b12df37984a449b57bae3f4120f70be177be0",
  "gasUsed": 135668,
  "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
  "status": false,
  "to": "0x4349baf4b5ba7d4c85cb7ecc7042278a8eb3a6d4",
  "transactionHash": "0xb0efb8a331d154c4c055d031ea2cabc66e3fa8161bf66c6e4f5c50bb71d5172c",
  "transactionIndex": 20,
  "events": {}
}
    at Object.TransactionError (errors.js?5f2e:93)
    at Object.TransactionRevertedWithoutReasonError (errors.js?5f2e:105)
    at eval (index.js?6248:474)

As you can see, the generated error doesn't specify the failure reason.
What is strange is that when I call this function on Remix IDE using the injected provider and metamask to connect to Ropsten test network, calling the function succeeds with no error.
Here is the transaction detail on Etherscan for the successful transaction
Here is the transaction detail on Etherscan for the failed transaction
I tried to fix the problem by providing enough gas in my function call in the frontend but it still didn't work.
This is how I call the function in the front end using web3.js:
 const accounts = await web3.eth.getAccounts();
            const plasticBaleSC = plasticBaleContract(this.props.address);
            await plasticBaleSC.methods.endAuction().send({ from: accounts[0], gas: 250983});

This is the function that I call in the smart contract

function endAuction() onlyOwner public{

        require( isOpen, "Auction is not avalible.");
        require(endTime < now, "Auction duration is not up yet.");
        require(highestBidder != address(0), "No bids have been placed");

        isOpen = false;

        uint halfAmount = highestBid/2;

        (auctionOwner).transfer(halfAmount);

        uint contributionRate =0;
        uint reward;

        for(uint i=0; i < contributors.length; i++){
                uint j;
             for(j=0; j < i; j++)
                  if(contributors[i] == contributors[j])
                      break;
                if(i==j)
                tempArray.push(contributors[i]);
              }

        for(uint i=0; i < tempArray.length; i++){
            contribution=0;
             for(uint z=0; z < contributors.length; z++){
                  if(tempArray[i] == contributors[z])
                      contribution++;
             }
             contribution = contribution *100;
             contributionRate = contribution / (plasticBale.length);
             reward = ((contributionRate * halfAmount)/ 100)+1;
             tempArray[i].transfer(reward);
             rewardRecycler(tempArray[i], reward);

        }

          for(uint i=0; i< plasticBale.length; i++)
          updateBottleStatus(highestBidder, plasticBale[i]);

        emit auctionEnded(address(this), highestBidder, highestBid , now);

    }

modifier onlyOwner{
        require(msg.sender == auctionOwner, "Auction owner is not authorized");
        _;
    }

You can find the full smart contract code in this EthFiddle


texts:
I'm trying to run a private testnet (OSX, geth v1.3.5) but finding that mining is either not starting properly or is extremely slow.

I am using a custom genesis json as follows:

{
"nonce": "0x0000000000000042",
"timestamp": "0x0",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"extraData": "0x0",
"gasLimit": "0x8000000",
"difficulty": "0x400",
"mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"coinbase": "0x3333333333333333333333333333333333333333",
"alloc": {
}}

And I am starting geth with the following flags:

    geth --identity "testnet" --genesis <filepath to my gensis.json> --rpc --rpcport "8000" --rpccorsdomain "*" --datadir <filepath to empty folder> --port 30303 --nodiscover --ipcapi "admin,db,eth,debug,miner,net,shh,txpool,personal,web3" --rpcapi "db,eth,net,web3" --autodag --networkid 1900 --nat "any" --verbosity 3 console

Running a testnet like this right now, and have mined 1 block in about 6 minutes. Hashrate is currently 2600. The logs I see in the console though don't seem to be indicating that mining should be this slow:

I0313 17:00:16.201128     845 worker.go:348]   Mined block (#1 / 43640ff2). Wait 5 blocks for confirmation
I0313 17:00:16.216848     845 worker.go:569] commit new work on block 2 with 0 txs & 0 uncles. Took 12.437538ms
I0313 17:00:16.219133     845 worker.go:569] commit new work on block 2 with 0 txs & 0 uncles. Took 1.237624ms

A few weeks ago I was able to get a testnet running with a difficulty of 0x400 and it was giving me a block every second, haven't been able to figure out why this is stalling so much.


texts: Passing constructor arguments while deploying contract from byte code

texts:
I am trying to deploy a contract via MyEtherWallet from byte code generated by browser-solidity. I unlocked my wallet using private key,but I didn't find any way of passing parameters to contract's constructor. How can I do that?

This makes me doubt whether I will be able to call all functions of my contract from MyEtherWallet as I was able to do using Mist.
I am using MyEtherWallet as substitue to Mist because it saves me from downloading blockchain data.But not sure whether this will work as substitue of Mist for deploying and accessing contracts.

Edit 1: Even on deploying contract from Mist using byte code doesn't give any option to choose for a contact and pass parameters to contract. While deploying contract from source code works as good as expected.


texts: Error: Cannot find module 'bignumber.js'

texts:
I'm trying to test this smart contract but I can't seem to get the beyond this error, I'm using the latest truffle suite v5.1.16, and web3 v1.2.6.

KTokenSale.test.js

const BigNumber = web3.BigNumber;

require('chai')
  .use(require('chai-bignumber')(BigNumber))
  .should();

  const KToken = artifacts.require('KToken');
  const KTokenCrowdsale = artifacts.require('KTokenCrowdsale');

  contract('KTokenCrowdsale', function([_, wallet, investor1, investor2]) {
    beforeEach(async function () {
        this.name = 'TestToken';
        this.symbol = 'TT';
        this.decimals = 16;

        this.token = await KToken.new(
            this.name,
            this.symbol,
            this.decimals
            );

        this.rate = 850;
        this.wallet = wallet;

        this.crowdsale = await KToken.new(
            this.rate,
            this.wallet,
            this.token.address
            );
    });
  });

  contract('crowdsale', function() {
    it('tracks the rate', async function() {
        const rate = await this.crowdsale.rate();
        rate.should.be.bignumber.equal(this.rate);
    });

    it('tracks the wallet', async function() {
        const wallet = await this.crowdsale.wallet();
        wallet.should.equal(this.wallet);
    });

    it('tracks the token', async function() {
        const token = await this.crowdsale.token();
        token.should.equal(this.token.address);
    });
  });

Smart contract code being tested:

pragma solidity ^0.5.11;

import "@openzeppelin/contracts/crowdsale/Crowdsale.sol";
import "@openzeppelin/contracts/crowdsale/validation/CappedCrowdsale.sol";

contract KTokenCrowdsale is Crowdsale, CappedCrowdsale {
    uint256 public investorMinCap = 7000000000000000000;
    uint256 public investorMaxCap = 350000000000000000000;
    mapping(address => uint256) public contributions;

    constructor(
        uint256 _rate,
        address payable _wallet,
        IERC20 _token,
        uint256 _cap
    )
    Crowdsale(_rate, _wallet, _token)
    CappedCrowdsale(_cap) public {}
}


texts: how to create genesis block on ethereum?

texts:
geth --datadir ./ init customgenesis.json

Fatal: Failed to read genesis file: open customgenesis.json: no such file or directory


texts:
After the attacks the clients are shit. At the moment, I am unable to download any blocks, except if I delete all the chaindata and it starts again.

I have less than 6k blocks left to download and I am stuck. It is the second time I've downloaded the entire chain...

Please help me with what to do. There are no detailed instructions anywhere, for noobs. ELI5 please. I've been trying everything apart from Parity. Tried all the other clients. Also, the 64bit Ethereum wallet is making my computer way too slow, to the point that it freezes many times...

I need to use the client tomorrow. I don't want to trust/rely on any web wallet.

Thanks for your time.