texts: What is a suitable pattern for building a web/mobile app that leverages ether?

texts:
Noob to ether dev.

Looking to understand how to build an app that leverages Ethereum - what suitable patterns are out there (ideally to go via some tutorials).

A few apps examples (from easy to complicated) that I would think would be supported but I'm not sure the architecture that makes the most sense for the platform:

Simple app (mobile, web, and/or desktop) that allows a user to pay a bit of ether to take a message, hash it, and put the result on the blockchain for all to see (and more importantly, verify that something was known/sent at a particular time)
Service app that takes emails and does similar to the above (I'd think both would batch) - giving strong assurances (via the blockchain) that someone wrote something or other at some particular time (e.g. useful in contract negotiation)
Complex app that would allow for binding arbitration - agreeing on a pool of arbitrators based on reputation, putting up crypto to pay the arbitration fees, and (possibly) putting up crypto for the arbitration to be self-executing. Most of this could be via a front end but blockchain would make all of it independently verifiable.

Again, I'm quite new but it seems to even get a wallet and some gas that one could use on a mobile device or pay via an app (like one can with AliPay/WeChat) is not a  capability that exists now. Given this, what would appropriate development architectures/patterns for the above apps be?


texts: how to call a function with ether through web3

texts:
I'm writing a simple DApp in webpack sample(metacoin) in truffle,there is a function that need to call with 2 ether and 1 input parameter. And my question is how to call that function in the index.js,should i use xx.methods.function().send(from:,value:)?

Thanks so much.


texts:
I'm trying to repeat that tutorial - https://medium.com/@wagnertrindade/ethereum-compile-deploy-and-interact-with-smart-contracts-e65bd42a1a0

everything looks good, but getter always returns 0.

geth version - 1.8.11-stable

node started with:
geth --rpc --rpcport "8001" --rpccorsdomain "*" --datadir "~/node" --port "30303" --rpcapi "db,eth,net,web3,personal" --identity "zero" --networkid 733 mine

genesis.json:
{
    "config": {
        "chainId": 42,
        "homesteadBlock": 0,
        "eip155Block": 0,
        "eip158Block": 0
    },
    "nonce": "0x0000000000000042",
    "timestamp": "0x0",
    "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "gasLimit": "0x8000000",
    "difficulty": "0x1",
    "mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "coinbase": "0x3333333333333333333333333333333333333333",
    "alloc": {
        "1da3639d184d47f380f8428957bffc09a3914679": {
            "balance": "20000000000000000000"
        }
    }
}

Smart Contract: StorageExample - https://solidity.readthedocs.io/en/v0.5.10/introduction-to-smart-contracts.html

What's wrong here?


texts: msg.sender is different from chosen account in Metamask when checking from constructor

texts:
I am trying to do a comparison of msg.sender and another address inside a contract constructor. The problem is that in the constructor, msg.sender is a different address from the one I chose in Metamask.

constructor() public {
        emit constructorInit(msg.sender); // for debugging
        if(msg.sender == issuer) { // fails
            ...
        } else {
            ...
        }
    }

Address chosen through Metamask: 0x08947c98C28054e1D1B17F8351F880aF8f5ba0eC

Value of msg.sender(obtained from event): 0x72f29a5fb7cca78d79370737561dce9c1d73a4ce

However, web3.eth.getCoinbase() does return the expected address 0x08947c98C28054e1D1B17F8351F880aF8f5ba0eC

On Metamask, it's connected localhost 7545 which corresponds to the server on Ganache/Truffle.

web3 version: 1.2.4
solidity version: 0.5.12;


texts: Constructor initializing another contract

texts: I have a contract which is creating an instance of another contract. I am confused about deploying the contracts in Truffle. Does the constructor get initialized when deployed?


texts: Mapping: Does the length of the key as string affects the gas usage?

texts:
I am using string as a key on mapping data structure.

[Q] While we are use mapping, when the length of the key string increases, does it also increase the gas usage?

mapping(string => int) map;

contract.array("mykey");                                 //short key length.
contract.array("mykey_mykey_mykey_mykey_mykey_mykey");   //longer key length is used.

function array(string key){
    map[key] = 10;
}

Thank you for your valuable time and help.


texts: What does this means?network/artifact mismatch Contract has not been deployed to detected network but when i write truffle network i can see mine.


texts:
Other than multichain is utxo based and quorum is account based, what are some major differences between multichain and quorum?

Scalability, consensus, turing complete language support, etc.


texts:
Friends. I'm trying to learn.
Thank you for your patience with my English.

Is it possible to move ether between my accounts without paying the transfer fee?

For exmaple, move 1.5 ETH from eth.account[0] to eth.account[1].

without paying the transfer fee ?


texts: importing a contract does not access to its modifiers

texts:
Contract A imports Contract B and Contract B contains a modifier that I want to use in contract A. Contract A is set to inherit from Contract B, however I get the following when I try to use the modifier in Contract A:

Error: solc: exit status 1
<stdin>:1:1: Error: Declaration "modifierInB" not found in "B" (referenced as "./B").
import {modifierInB} from "./B";
^--------------------------------^

I have tried this with the below with similar results

import "./B";

Any idea where I'm going wrong or can I simply not move a Contract containing a modifier to another file?


texts: Achieving ZERO fee ethereum transactions like EOS

texts: How would Ethereum take on the approach of how EOS have ZERO fees when making a transaction? EOS has the concept of resources, but is there anything like this in the works of "shared resources" for Ethereum? Does the upcoming POS upgrade provide something similar or does GAS Fees always have to play a factor in running smart contracts?


texts: Monax :-Issue in executing job configuration file

texts:
I am using Monax version 0.18.0.I am following the tutorial for deploying contracts  in Monax https://monax.io/docs/getting-started/. I have used the sample contract defined in their starting tutorial.

 pragma solidity ^0.4.0;

 contract IdisContractsFTW {
    uint storedData;

    function set(uint x) {
        storedData = x;
    }

    function get() constant returns (uint retVal) {
        return storedData;
    }
 }

I have used the epm.yaml file in their tutorial.

   jobs:

   - name: setStorageBase
      job:
          set:
              val: 5

 - name: deployStorageK
     job:
       deploy:
            contract: idi.sol

- name: setStorage
      job:
        call:
           destination: $deployStorageK
           data: set $setStorageBase

- name: queryStorage
      job:
        query-contract:
              destination: $deployStorageK
              data: get

- name: assertStorage
     job:
       assert:
          key: $queryStorage
          relation: eq
          val: $setStorageBase

On executing the configuration,it won't generate the deployed address for contract.

Consider this issue as a follow up to the question Issue in creating App using Monax :- Contract not found in JSON.

As mentioned I have updated the epm.yaml file by omitting the job field for the contract idi.sol.

jobs:

   - name: setStorageBase
        set:
        val: 5

    - name: deployStorageK
         deploy:
         contract: idi.sol

    - name: setStorage
         call:
         destination: $deployStorageK
         data: set $setStorageBase

    - name: queryStorage
        query-contract:
        destination: $deployStorageK
        data: get

  - name: assertStorage
      assert:
         key: $queryStorage
         relation: eq
         val: $setStorageBase

I have got the issue as follows:-

    Sorry, the marmots were unable to load the monax jobs file. Please check your path: While parsing config: yaml: line 3: mapping values are not allowed in this context

Any help is appreciated.


texts: How to wait for balanceOf before I execute a transfer?

texts:
Ok, I'm new into JS and web3 and MetaMask. I'm still lost about Promise and async/await after reading them for 5 times!

I want to call my smart contract balanceOf method to check if there's enough balance of token before I execute a transfer.

How do I actually wait for this balanceOf value to return to my JS script then only I proceed?

You know, getting the balanceOf takes like only 1 sec, but I know sometimes the user's finger is faster than the brain.

I tried async/await function below but my main code doesn't "wait", it just continues on. I'm using web3 1.0.

Then, I execute the transfer in a separate function. What I'm doing now is firstly I set the token balance using setTokenBalance(balance). Then check if I have enough balance by calling getTokenBalance(). If yes, then I do the transfer. Which works but it's kinda funny cos there's a split second that getTokenBalance shows '0' since it hasn't got the correct balance data.

var tokenBalance = 0;
async function retrieveTokenBalance(contract, walletAddress) {

      await contract.methods.balanceOf(walletAddress).call(function(err,res){
            if(!err){
                console.log(res);
                setTokenBalance(res);
            } else {
                console.log(err);
            }
        });

}

function setTokenBalance(balance) {
    tokenBalance = balance;
}

function getTokenBalance() {
    return tokenBalance;
}


texts: Centralized to Decentralized (Is it transferable?)

texts:
I do not know much about Blockchain tech, but it seems like it's the future. However, what happens to everything that already exists?

E.g., would an existing domain registrar be able to transition to be part of Blockchain or things such as Ethereum?

Lets say there's a social network with 5,000 members. Would the admin be able to transfer the entire website from Hosting Provider Whatever to Blockchain? If so, do you think traditional domains get transferred over one day too?

For example, what happens to a huge company like GoDaddy? What happens to the .com, .net, and .org extension? Does all of this transfer to Blockchain tech? If not, is everyone in the existing WWW going to lose business?

As of now, Ethereum is using a .org extension that was issued by some sort of centralized company who sells .org domains no? How is this all going to work??

I'd hate to see premium .com domains have 0 value if it can no longer be used to what everyone will soon (possibly) adapt to.

I hope I made sense. SUPER important question for a tonnnnnn of reasons, and people.


texts: Is geth being deprecated? eth seems to receive so much more development

texts: By checking the github activity, geth seems to fall behind eth. Would love to hear about it's future and maybe something about the why's (likely to be related because it's in golang).


texts: How to use a contract deployed by my friend on my private blockchain?

texts:
My friend and I are using geth and have the same private blockchain.
He has deployed a contract and is able to invoke its functions after mining it.

Is it possible for me to call his contract functions without having to deploy the contract by myself?

Also what is the significance of mining for deploying a contract?


texts:
how to make transaction like THIS TRANSACTION

anyone can help me how to build it


texts: Deploying a smart contract from EVM Bytecode via rpc calls

texts:
I am currently trying to deploy a smart contract with bytecode in a private Ethereum chain, using the "dev" chain of the parity client. For this, I compiled the following contract:

pragma solidity ^0.4.11;

contract MyContract {
    uint i = (10 + 2) * 2;
}

with solidity:

solc --bin test.sol

======= test.sol:MyContract =======
Binary:
    608060405260186000553480156014576
    00080fd5b5060358060226000396000f3006080604052600080fd00a165627a7a72305820d0cc3f28b74510b6f3f34e1a1e1303c584b355320f387a3e30022117e3554e220029

I then used the following rpc call to create the transaction:

Request: {"method": "personal_sendTransaction", "id": 1, "jsonrpc": "2.0", "params": [{"from": "0x0053b6a9527c2ba72cf44486dd12d9930ce25bae", "data": "0x60806040526018600055348015601457600080fd5b5060358060226000396000f3006080604052600080fd00a165627a7a72305820d0cc3f28b74510b6f3f34e1a1e1303c584b355320f387a3e30022117e3554e220029"}, "test"]}.

where 0x0053b6a9527c2ba72cf44486dd12d9930ce25bae is an account on the private Chain which has ether and the passphrase test.

This is the answer I get:

Response: {"jsonrpc":"2.0","result":"0xf547c28a3f51c05832fadd4b807f5bb769196970d08e446b2644a2ea94359572","id":1}.

But the byte string given in result is not a valid address. How do I get the address of the contract I created?


texts: ELI5 what are VDFs and why are they important for Serenity?

texts:
At Devcon4, Justin Drake presented VDFs and their role in PoS in the upcoming network upgrade of Ethereum, Serenity. He described the importance of the Ethereum Foundation in securely generating entropy and distributing hardware in order to properly set up these functions.

Could someone provide an explanation in layman terms on how Verifiable Delay Functions (VDFs) work?


texts:
When one deploy a smart contract in the Ethereum network, the creator adds on it a gas limit and a gas price for transaction. Then, a miner executes the contract to verify the transaction and he gets the gas by the creator. My questions are:

1) Does all the hosts in the network execute the smart contract, after the miner puts it in a block?

2) If it is so, does they take some ether/gas by doing this by the creator of the contract? If not, does this mechanism do not entail any economic losses to hosts?


texts: I understand PoW uses gas to counter a DDoS attack. What about PoA? Is gas also used in PoA networks?


texts: Using openzeppelin-test-environment to test upgradeable contract

texts:
openzeppelin-test-environment is quite a new package, it doesn't tell how to initialize the upgradeable contract
https://github.com/OpenZeppelin/openzeppelin-test-environment
Just a basic example from the link above:
const { accounts, contract } = require('@openzeppelin/test-environment');
const [ owner ] = accounts;

const { expect } = require('chai');

const MyContract = contract.fromArtifact('MyContract'); // Loads a compiled contract

describe('MyContract', function () {
  it('deployer is owner', async function () {
    const myContract = await MyContract.new({ from: owner });
    expect(await myContract.owner()).to.equal(owner);
  });
});

How to add an upgradeable contract which doesn't have constructor but initialize method?


texts: Value of converting million Ethereum from an ICO

texts: When an ICO get x millions in Ethereum, how would that convert to dollars? I assume the market would come down crashing if they places that in one go, but would it be possible to sell batches of 100 thousand every now and then and indeed get x million in dollars?


texts: How is uniswap/sushiswap distributing their fees?

texts:
As i know, Sushiswap is collecting a 0.3% fee that is then divided into two parts

0.25% goes to LP providers
0.05% goes to treasury for burn

note, 0.5% isn't indicated but I suppose that's the case after looking at code const BASE_FEE = new Percent(JSBI.BigInt(30), JSBI.BigInt(10000)) and 0.05% has to go somewhere, pancake is burning it for example
Now, As I mentioned above, the fee is defined in frontend code, JSBI.BigInt(30). But I can't find where are they splitting this 30 fee.
There is a code in the backend, a formula that is also stated in Uniswap whitepaper (v2), That might be doing job. They've mentioned 1/6 of growth in sqrt(k) that initially I didn't understand whats how is that related to formula or this fee distribution (yeh, I'm dumb at math things).
My deduction is this - 1/6 (that is roughly 1.16) multiplied by 0.3%, their initial fee and you get 0.048 that is 0.05 right? and since the treasury fee is 0.05 as well, is this the case?
For recheck, I did the same for pancakeswap, which is collecting 0.2% JSBI.BigInt(20) fee, doing same as above you get 0.032 that is 0.03, and their treasury distribution is 0.3%.
I know, I might be looking at big coincidence or just number play that might sound a bit stupid for experienced developer, but I will take a risk to ask - In code, Where is shushiswap or uniswap 0.3% fee is divided into LP providers and treasury.


texts: how do we know if transaction is rollback?

texts:
Transaction can be rollback because of various reasons, One of the reason can be, transaction run out of gas before it complete.

How do we know whether Transaction has rollback or not?

Is Ethereum provide any event or error which is use to find rollback transaction?


texts: Can Mist be attached to a Geth node on a different computer over HTTP RPC?

texts: I gather that Mist will automatically look for Geth on a local machine via IPC to save it maintaining its own blockchain. Is it possible to tell it to look for an instance of Geth on another machine via HTTP RPC?


texts: What happens when memory is full in a node?

texts: I am using go-ethereum and running a private blockchain network. I want to what is supposed to happen when the memory is full in the nodes. Will the program stop abruptly or will the old blocks get deleted?


texts:
I'm developing a new token and I'm curious how I can interact with the token after is build and deployed. For example:
Token1 has 10M tokens of total supply, I want people to can get those tokens, how I can do that? Also, I want transfers between people, which holds my token, and connecting my contract to a wallet.
Is even that possible with smart contracts?
Thank you in advance.


texts: Most efficient way to get all non-zero storage locations for a smart contract?

texts:
I'm looking at a mainnet smart contract and want to figure out all storage positions/slots where the storage has a non-zero value.

Is there a way to do this other than replaying and tracing all storage write/SSTORE operations during all contract transactions involving this contract?


texts:
I can't seem to figure what is wrong with my function, the debugger keeps spawning flame spitting dragons on the 'priceOfItem' variable.

function purchaseItem(uint256 _itemID, uint256 _itemQuantity) public {
            require(itemData[_itemID].inStock);
            require(_itemQuantity > 0);

            uint256 priceOfItem = itemData[uint256(_itemID)].unitPrice.mul(_itemQuantity);

            token.approve(contract, priceOfItem);
            token.transferFrom(msg.sender, wallet, priceOfItem);
            itemData[uint256(_itemID)].itemQuantity = itemData[uint256(_itemID)].itemQuantity.sub(_itemQuantity);
            emit ItemPurchased(msg.sender, _itemID, _itemQuantity, (priceOfItem));
        }


texts: We have launched a pre-order token and are wanting to reward people for interacting with us. What is the best way to perform an airdrop to around 500 people if the token has already launched? Should we use a code with an interface to the token and would we need to make an array of 500 people or is their a limit? If there is already a code floating around at there that does this could I please have a link? Thanks in advance!


texts: Running solidity-coverage with truffle gives error: can not find 'coverageEnv/migrations'

texts:
Running solidity-coverage gives the following error:

$npm run coverage
...
Writing artifacts to ./build/contracts

Launched testrpc on port 8555
Running: node --max-old-space-size=4096 ../node_modules/.bin/truffle test --network coverage ../tests/test0.js
(this can take a few seconds)...
Using network 'coverage'.

Error: ENOENT: no such file or directory, stat '/Users/solo/git/my-contract/coverageEnv/migrations'
Cleaning up...
Shutting down testrpc-sc (pid 5715)
Event trace could not be read.
Error: ENOENT: no such file or directory, open './allFiredEvents'
Exiting without generating coverage...
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! my-contract@0.0.1 coverage: `solidity-coverage`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the my-contract@0.0.1 coverage script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/solo/.npm/_logs/2018-10-07T17_16_27_017Z-debug.log

.solcover.js

module.exports = {
    copyPackages: ['zeppelin-solidity'],
    compileCommand: 'node --max-old-space-size=4096 ../node_modules/.bin/truffle compile --network coverage',
    testCommand: 'node --max-old-space-size=4096 ../node_modules/.bin/truffle test --network coverage ../tests/test0.js',
    port: '8555',
    skipFiles: []
};

truffle-config:
...

module.exports = {
  networks: {
    ...
    coverage: {
      host: 'localhost',
      network_id: '*', // eslint-disable-line camelcase
      port: 8555,
      gas: 0xfffffffffff,
      gasPrice: 0x01,
    }
  },
};

Running the testrpc and the test manually works just fine. But when running with solidity-coverage, for some reason it can't find the migrations dir in coverageEnv.

Any indication would be much appreciated. Thanks!

EDIT:

Although there might be a more elegant way to fix it, I managed to workaround this issue by copying the migrations scirpt as part of the testCommand: testCommand: 'cp -a ../migrations ../coverageEnv && node --max-old-space-size=4096 ../node_modules/.bin/truffle test --network coverage ../tests/test0.js',


texts:
is there any C# version of the offline signer for transaction. like ethereumjs-tx

var Tx = require('ethereumjs-tx')
var privateKey = new Buffer('e331b6d69882b4cb4ea581d88e0b604039a3de5967688d3dcffdd2270c0fd109', 'hex')

var rawTx = {
  nonce: '0x00',
  gasPrice: '0x09184e72a000',
  gasLimit: '0x2710',
  to: '0x0000000000000000000000000000000000000000',
  value: '0x00',
  data: '0x7f7465737432000000000000000000000000000000000000000000000000000000600057'
}

var tx = new Tx(rawTx)
tx.sign(privateKey)

var serializedTx = tx.serialize()
console.log(serializedTx.toString('hex'))

need similar in c# i am trying nethereum this implementation not working

How can I sign a transaction using c#?

var privateKey = "0xb5b1870957d373ef0eeffecc6e4812c0fd08f554b37b233526acc331bf1544f7";
var senderAddress = "0x12890d2cce102216644c59daE5baed380d84830c";

Now using web3 first you will need to retrieve the total number of transactions of your sender address.

var web3 = new Web3();
 var txCount = await web3.Eth.Transactions.GetTransactionCount.SendRequestAsync(senderAddress);

The txCount will be used as the nonce to sign the transaction.

Now using web3 again, you can build an encoded transaction as following:

var encoded = web3.OfflineTransactionSigning.SignTransaction(privateKey, receiveAddress, 10, txCount.Value);

If you need to include the data and gas there are overloads for it.

You can verify an encoded transaction: Assert.True(web3.OfflineTransactionSigning.VerifyTransaction(encoded));

Or get the sender address from an encoded transaction:

web3.OfflineTransactionSigning.GetSenderAddress(encoded);

To send the encoded transaction you will "SendRawTransaction"

var txId = await web3.Eth.Transactions.SendRawTransaction.SendRequestAsync("0x" + encoded);


texts: How is Ethereum gas distrubuted to miners?

texts: How is ethereum gas emitted to miners exactly?   The more you mine, the more gas you earn?  How does the Gas/Ethereum get to the miners wallet?


texts: How do I retrieve funds sent to wrong address that doesn’t exist

texts: I sent some funds to my MEW wallet but I fat fingered the address and sent it to a different address that does not seem to exist. How do I claim that address to retrieve funds I see sitting in the block.


texts: I've been trying to sync my ETH node for some days now, but I am noticing it is taking too long. Can anyone of you who has a full node tell me how many knownStates there are? thanks.


texts:
Instead of transferring my Eth token to my wallet, I accidentally sent it to the contract address of of the offshift XFT token
0xabe580e7ee158da464b51ee1a83ac0289622e6be
Would the contract creator be able to send it back to me?


texts: Invalid number of arguments to Solidity function when trying to retrieve dynamic array from web3.js

texts:
I have
struct Receipt {
        bytes32 domainName;
        uint256 amountPaid;
        uint256 timeBought;
    }
mapping(address => Receipt[]) public receipts;
I am trying to retrieve the whole array with web3.js like this:
this.DDNSCore.methods.receipts(checksumAddress).call();
 And I get the aforementioned error. If I give an integer index as a second parameter to the function, it manages to retrieve me the Receipt, which is at that index of the array.
Is there a way to get the whole array?


texts: I've sent ether from testnet to mainnet but didn't receive anything. Why?

texts:
A few days ago I made a transaction at an address known to me (tx made from testnet to global main net). The transaction took place and received over 6 confirmations. The next day this transaction was no longer in the list of committed transactions. The Ether did not reach the destination address (in main net), but they did leave my address (in testnet).

Link to the transaction on etherscan.

Why has the destination address still not received Ether?

I understand about can't transfer ethers from testnet to any other net.
Thanks to all for help...


texts: Does the amount of ETH in staking have to be exactly 32 ETH or only at least 32 ETH?

texts: The amount of ETH to be put at stake in phase 0 of Ethereum 2.0 is at least 32ETH but, is it also a maximum? I know that the possibilities of being chosen to propose blocks depends in the amount of ETH at stake but I don't know if at phase 0 only fixed stake validators are allowed.


texts: Is there a specific procedure to deploy a smart contract/dapp to the public network (Mainnet)?

texts:
I would like to know if there are any rules (coding rules and verification steps to be taken) that should be taken care of and controlled by someone who is maintaining the Mainnet such as the Ethereum Consortium etc. while deploying a smart contract / dapp to the Ethereum public network (Mainnet)?

And is it obligatory to provide the source of the smart contract/dapp in a git repository or not?

Or can anyone without being controlled by someone else deploy his/her app to Mainnet as he/she wants?

I have found these related questions but they do not answer to my question.

how to deploy smart contract in ethereum network using ropsten network?
What are explicit steps to deploy dapp to mainnet?

Any ideas?

Thanks in advance.


texts: What is wrong with my Smart-Contract method-execution in web3Js?

texts:
I have a problem by executing the following smart contract. It's a simple escrow-smart-contract and I want to execute it in web3JS version 1.0.
The contract should be valid but there is not effect when I execute the method payoutToSeller(). The seller should get 5 ether back, but that's not the case. Can someone help me?

const Web3 = require("web3");
const solc = require("solc");
let web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));

let getBalance = (acc) => {
  return new Promise((res, rej) => {
    let balance = web3.eth.getBalance(acc).then((data, error) => {
      if (!error) {
        let ethers = web3.utils.fromWei(data, "ether");
        res(ethers);
      } else {
        rej("Requesting balance failed.");
      }
    });
  }).catch((e) => {
    console.error(e)
  })
}

let source = `pragma solidity ^0.4.20;
contract Escrow {
  address public buyer;
  address public seller;
  address public arbiter;

  function Escrow(address _seller, address _arbiter) public payable {
    buyer = msg.sender;
    seller = _seller;
    arbiter = _arbiter;
  }

  function payoutToSeller() public {
    if (msg.sender == arbiter || msg.sender == buyer) {
      seller.send(this.balance); // this = contract
    }
  }

  function refundBuyer() public {
    if (msg.sender == arbiter || msg.sender == seller) {
      buyer.send(this.balance);
    }
  }

  function getBalance() constant returns (uint) {
    return this.balance;
  }
}
`

let main = async () => {
  let accounts = await web3.eth.getAccounts();
  let buyer = accounts[0];
  let seller = accounts[1];
  let arbiter = accounts[2];

  // compile the solidity code
  let compiled = solc.compile(source);

  // save public interface of contract
  let abi = JSON.parse(compiled.contracts[":Escrow"].interface)

  // create var with contract
  let Escrow = new web3.eth.Contract(abi);

  console.log("Before:");
  console.log("\tBuyer: " + await getBalance(buyer));
  console.log("\tSeller: " + await getBalance(seller));
  console.log("\tArbiter: " + await getBalance(arbiter));
  console.log("\tContract: 0\n");

  // deploy contract
  let deployContractTx = Escrow.deploy({
    data: compiled.contracts[':Escrow'].bytecode,
    arguments: [seller, arbiter]
  });

  let calculatedGas = await deployContractTx.estimateGas();

  let contractInstance = await deployContractTx.send({
    from: buyer,
    gas: calculatedGas,
    value: web3.utils.toWei('5', "ether")
  });

  console.log("After sending the contract:");
  console.log("\tBuyer: " + await getBalance(buyer));
  console.log("\tSeller: " + await getBalance(seller));
  console.log("\tArbiter: " + await getBalance(arbiter));
  console.log("\tContract: " + await getBalance(contractInstance.options.address) + "\n");

  //
  //everything works fine until here.
  //

  await contractInstance.methods.payoutToSeller().call({from: arbiter});

  console.log("After the arbiter allowed the payout:");
  console.log("\tBuyer: " + await getBalance(buyer));
  console.log("\tSeller: " + await getBalance(seller));
  console.log("\tArbiter: " + await getBalance(arbiter));
  console.log("\tContract: " + await getBalance(contractInstance.options.address) + "\n");

}

main();


texts: How to calculate an Ethereum Contract's address during its creation using the Solidity language?

texts:
Now I know and have read the other thread saying that a contract's address is created deterministically via RLP encoding the creator's address and his nonce and then hashed with Keccak-256 but the problem is the solution is provided in Python.

I am currently coding in Solidity and although I have tried porting the solution over to Solidity, Solidity does not support multi-type arrays to my knowledge which is required by the rlp_encoder function. Any help or tips on how to achieve this in Solidity would be appreciated! (The nonce would be given as input during the contract creation)


texts: Problem with the code for fetching data from ether scan

texts:
I am trying to fetch ICO data via python from etherscan.io through the API but hitting a problem.

I am using the code by Corey Petty for python bindings also using his code for ICO analysis

Full code here.

When I execute transactions = api.get_all_transactions(), it just keeps adding pages and never stops until i restart the kernel.

Please guide.

Thanks


texts:
I was reviewing the blockchain technology the other day, Maybe this is not the right place or maybe I should rephrase my question but..

Blockchain is peer to peer, every peer stores the data
Data is only added... no updates/deletes

so my questions are:

As we create more and more blocks, isnt it become slower and slower to get the data?
Extra overhead on network?

Suppose there are organizations A, B, C, D. they decide to use blockchain, join the network.

  A creates few blocks
  B creates few blocks
  C and D do not create any blocks

still all the blocks get copied to all organizations
I mean in multiple enterprise scenario why organization A should care about data from B?
also there may be thousands of GBs of data, and it is copied all over the places
doesnt this gives extra overhead to the network?

update

suppose the network becomes super slow because some random reason

  organization A creates chain1 and creates few blocks within it say block1, block2
  after a small interval
  organization B creates few blocks withing chain1 say block3

obviously it takes some time to sync the blocks within the peers A & B
now as a user of blockchain what is the guarantee that I will always get latest data?
I mean the user may get block2 as latest or maybe block3 as latest one


texts: How to compute ethereum contract address with java?

texts:
I'm looking for the java version of the solution of this question.

How is the address of an Ethereum contract computed?

Actually I want have a solution of the problem below.

I have a master contract which creates many sub contracts.
And I need to get the addresses of the sub contracts when it's created.

master contract creates sub contract with a function like this

function createForwarder() public returns (address) {
    return new Forwarder();
}

But I can't get the address from this function. I'm using web3j and it has not internal transaction concept. So I need to get the address with another way.

What will be the best solution for me?


texts: Subscribing to events using ethers / hardhat network

texts:
I have a basic node express application. It connects to my locally running hardhat network via ethers & websocket. The connection seems to work, since I can query the blockchain succesfully (for instance await ethers.getBlockNumber() returns the correct block number).
However, my event listeners do not seem to work. The callbacks are never triggered.
Code example:
I'm using a loader function when I initialize the express app. When it is executed, I connect to the websocket provider. Then I successfully print the current block number to the console. Then I register an event listener on the "block" event (taken from the documentation). However, the listener never fires.
I'm connecting to the hardhat network, which is configured to produce a new block every five seconds (I can see that this is the case in the hardhat console). I would expect the listener to be fired every five seconds, always when a new block is mined.
What am I missing?
import { ethers } from "ethers";

export default async ({ expressApp }) => {
  const provider = new ethers.providers.WebSocketProvider(
    "ws://localhost:8545"
  );

  console.log(await provider.getBlockNumber());

  provider.on("block", () => console.log("new block"));

  expressLoader({ app: expressApp });
};

EDIT:
If I use the JsonRpcProviderinstead of WebSocketProviderand the following url http://localhost:8545 the callbacks are fired. What do I need to do to achieve the same behavior with websocket?


texts: Interact with smartcontracct via web3.js: Uncaught TypeError: MyContract.at is not a function

texts:
I'm trying to interact with my smartcontract but get the error: Uncaught TypeError: MyContract.at is not a function

My Code:

var web3 = require('ethereum.js');
web3.setProvider(new web3.providers.HttpProvider());

var MyContract = web3.eth.contract([{"constant":false,"inputs":[{"name":"x","type":"uint256"}],"name":"set","outputs":[],"type":"function"},{"constant":true,"inputs":[],"name":"get","outputs":[{"name":"retVal","type":"uint256"}],"type":"function"}]);

var result = MyContract.at("MyContractAddress").get();
console.log(result);

When I request default Geth functionality I get a correct response:

var version = web3.version.api;
console.log(version);  "0.2.4"


texts: Error in signing a raw transaction javascript -- calling a contract + attaching some msg.value

texts:
Here, I am trying to call a function(embrace) on a smart contract on Ropsten that needs two parameters and msg.value of 0.01 ether. But it's showing up the error that the msg.value is not sufficient. The rest of the functions(that don't need any msg.value attached to them) on the contract are working completely fine and also I am able to call and execute the function(embrace) form remix So, I am sure that there's no problem on the blockchain side code or the connection part.
what I understand is that I am not able to attach the value to the transaction properly. Please, can someone tell me what I am doing wrong here?
async function embrace(
  _value,
  _buyerName,
  _productID,
  passedpublickey,
  passedprivatekey
) {
  return new Promise(async (resolve, reject) => {
    const account = passedpublickey;
    const privateKey = Buffer.from(passedprivatekey, "hex");

    const contract = new web3js.eth.Contract(abi_assetMain, address_asset, {
      from: account,
      gasLimit: 3000000,
    });

    let valuethis = web3js.utils.toHex(web3js.utils.toWei("0.01", "ether"));
    console.log(
      "Contract Function:!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!",
      valuethis,
      _value,
      _buyerName,
      _productID,
      passedpublickey,
      passedprivatekey
    );

    const contractFunction = contract.methods.embrace(_buyerName, _productID);
    const functionAbi = contractFunction.encodeABI();

    let estimatedGas;
    let nonce;

    contractFunction
      .estimateGas({ from: account })
      .then((gasAmount) => {
        estimatedGas = gasAmount.toString(16);

        web3js.eth.getTransactionCount(account).then((_nonce) => {
          nonce = _nonce.toString(16);

          console.log("Nonce: " + nonce);
          let networkChainId = 3;
          let value = web3js.utils.toHex(Web3.utils.toWei("0.01", "ether"));
          const details = {

            to: address_asset,
            data: functionAbi,
            from: account,
            value: value,

            gasLimit: web3js.utils.toHex(3000000),
            gasPrice: web3js.utils.toHex(web3js.utils.toWei("100", "gwei")),
            nonce: "0x" + nonce,
            chainId: networkChainId,
          };
          const transaction = new EthereumTx(details, { chain: networkChainId });
          transaction.sign(privateKey);

          const serializedTx = transaction.serialize();

          web3js.eth.sendSignedTransaction(
            "0x" + serializedTx.toString("hex"),
            (err, id) => {
              if (err) {
                console.log("---error---:", err);
                return resolve("Error Sending Transactions");
              } else if (id) {
                const url = etherscanAxplorUrl + id;
                console.log(url);
                return resolve(url);
              }
            }
          );
        });
      })
      .catch((err) => {
        reject(err);
        console.log("error errerrerrerrerrerr", err);
      });
  });
}


texts: Transactions are mined before monitored transaction with same params (BSC)

texts:
On BSC chain, i am facing this situation.
I am scaning mempool for a transactions ( nodejs and web3.eth.subscribe('pendingTransactions', ...) ) and when i find the one i am concerned, i fire a transaction with same params (gas, gasprice). The weird thing (in my opinion) is that in many cases my transaction is mined in the same block but BEFORE the one i am monitoring. (eg mine is at position 10 in the block, monitored transaction at position 20)
It is assumed that this can happen?
As far as i have understand how miners works, network shouldnt allow transactions (with same gasprice) to overrun existed transactions with same params. Or i am missing something here?


texts: Is there a way to figure out if 2 (or more) address is belong to same HD Wallet account or not?

texts:
I'm a new to Wallet concept, I know that a HD Wallet structure is created from a root seed as Mnemonic Code, from that HD Wallet help to generate child keys as the meaning of multiple difference Ethereum Address.

So, is there a way that we can follow to figure out or verify if 2 address is belong to a HD Wallet (or the root seed) or not?

Many thanks for all contributing,


texts:
I can't seem to make the linker.linkBytecode() method to work...

Here's how I'm using it:

const linkedBytecode = linker.linkBytecode(mainContract.bytecode, {
        'UserLib': userLibContract.options.address
 });

If I try to console.log(linkedBytecode) it outputs the bytecode with placeholders that should've been replaced by the linker!

I noticed that the compiled bytecode of my mainContract outputs something like ...5173__IssueLib.sol:IssueLib_________________916.... whereas on the official documentation it says that it should output something like ...5173__IssueLib_______________916....

What Am I missing here?

Thanks in advance! :)


texts: How to verify access of child contracts?

texts:
I am using a factory A to produce child contracts. Now I want to guarantee that only these child contracts have access to a different contract B.

Using the factory as a proxy is somehow a detour as I also would like to send stuff back from B to the children. I thought using the nonce of the factory A would be great but this is not accessible in Solidity. Is there any other way?

Thanks!


texts: web3.eth.sendRawTransaction: cannot unmarshal hex string without 0x prefix

texts:
When I call sendRawTransaction, I got

  "[Error: invalid argument 0: json: cannot unmarshal hex string without
  0x prefix into Go value of type hexutil.Bytes]"

I think all of params have "0x" prefix. Could you share your ideas how to fix it?

I'm using testnet(ropsten).

var Web3 = require('web3');
var web3 = new Web3(new Web3.providers.HttpProvider("http://xxxxxx:xxxx"));

var Tx = require('ethereumjs-tx');
var privateKey = new Buffer('xxx', 'hex')

var rawTx = {
  nonce: '0x00',
  gasPrice: '0x5209', // eth_estimateGas rpc result
  gasLimit: '0x5208', // 21,000 in decimal
  to: '0x8005ceb675d2ff8c989cc95354438b9fab568681',
  value: '0x01'
}

var tx = new Tx(rawTx);
tx.sign(privateKey);

var serializedTx = tx.serialize();

console.log(serializedTx.toString('hex')); // f86180825208825208948005ceb675d2ff8c989cc95354438b9fab56868101801ca096e0cb2e633f07a7ee1f761dba1109c18a44550692305c03c72403ffa0b8fc12a012482fd916fa0a05396fadbf13b39619193e9f80dd5a0fd32086257cc3a11796

web3.eth.sendRawTransaction(serializedTx.toString('hex'), function(err, hash) {
  if (!err) {
    console.log(hash);
  } else {
    console.log(err); // [Error: invalid argument 0: json: cannot unmarshal hex string without 0x prefix into Go value of type hexutil.Bytes]
  }
});

Update 1

It worked after adding '0x' following joël saying.

web3.eth.sendRawTransaction('0x' + serializedTx.toString('hex'), function(err, hash) {

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


texts:
In my contracts i'm using ether transfers which requires Solidity compiler 4.10. With newly updated truffle and solcjs version 4.10. I still get the following error using Truffle to compile the contracts.

Error: Source file requires different compiler version (current compiler is 0.4.8+commit.60cc1668.Emscripten.clang


texts: Not connecting to private blockchain from another node on the network

texts:
I have a Desktop and Laptop.I have configured private blockchain on my Desktop(node1) and able to sync with it from Node2 Laptop.But I am not able to get connected to the contract deployed on Node 1 via a web page i created.

web3.version.getNetwork((err, netId) this function throws error Invalid JSON RPC response.

I am able to access the contract from web page located on my Desktop.

First Node  geth --identity "Node1" --rpc --rpcport "8545" --rpccorsdomain "*" --datadir <data-path-1> --port "<defaultport>" --rpcapi "db,eth,net,web3,personal,miner" --networkid 123 console 2>> logfile_1

Second Node  geth --identity "Node2" --rpcport "8545" --rpcaddr "xxx.xxx.xx.xx"  --rpccorsdomain "*" --datadir <data-path-2> --port "<defaultport>" --rpcapi "db,eth,net,web3,personal,miner" --networkid 123 console 2>> logfile_2


texts: Importing paper wallet using geth gives encoding error

texts:
Importing from a paper wallet(myetherwallet) gives:

Could not create the account: encoding/hex: invalid byte: U+007B '{'

I am using the private unencrypted key.

go 1.5.3,
Geth 1.3.5,
Waller 0.5.1,


texts: Unable ts start Bootnode, am new to private blockchian, Can anyone tell me what am i missing

texts:
bootnode : The term 'bootnode' is not recognized as the name of a cmdlet,
function, script file, or operable program. Check the spelling of the name,
or if a path was
included, verify that the path is correct and try again.
At line:1 char:1
+ bootnode -genkey boot.key
+ ~~~~~~~~
+ CategoryInfo          : ObjectNotFound: (bootnode:String) [],
CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException


texts: Cannot invoke contract function from Web3js, but work when invoke via Parity

texts:
Following function work as expected and record all Events as expected when invoke via Parity client (Parity v1.9.0-20171208 unstable)

function addMember(address newMember) payable public{
        require(msg.sender == _owner); // only the owner could introduce members
        uint i;
        bool bFound = false;

        for (i=0;i<_members.length; i++){
            if (address(_members[i]._key) == newMember) {
                bFound = true;
                LogMessage("Account already exist ",newMember,0);
                break;
            }
        }
        if (!bFound){
            _members.push(Member({
                _key:newMember,
                _balance:0,
                _totalTodate:0
                }));
            LogMessage("Account added ",newMember,0);
            }
    }

When I invoke this from Web3js using following function, it does not fail (null error object) but does not execute the contract function at all.

function invokeAddMember(){
    var abi = JSON.parse('<my ABI>');

    var contractAddress = <contrsct address>;

    console.log("Unlocking coinbase account");
    var password = "<my_password>";
    try {
      web3.personal.unlockAccount("<contract_address>", password);
    } catch(e) {
        console.log("Error - web3.personal.unlockAccount");
      console.log(e);
      //return;
    }

    var FundSplitter = web3.eth.contract(abi);
    var myFundSplitter = FundSplitter.at(contractAddress);
    var newAddress = <Address of an account already created>;

    myFundSplitter.addMember.sendTransaction(newAddress,
            { from: '<owner account with enough ether>', value: 200, gas: 30000},
            function (error) {
                if(!error){
                    console.log("addMember - Success");
                }
                else
                    console.error(error);
            });

    console.log("Contract Address",contractAddress);
    console.log('abi - ', abi);
    console.log('block # - ', web3.eth.blockNumber);
}

ABI for the addMember function looks like below.

{
    "constant": false,
    "inputs": [
        {
            "name": "newMember",
            "type": "address"
        }
    ],
    "name": "addMember",
    "outputs": [],
    "payable": true,
    "stateMutability": "payable",
    "type": "function"
}


texts: how to fetch net worth of a given address?

texts:
Take this whale wallet for example:
https://etherscan.io/tokenholdings?a=0xa929022c9107643515f5c777ce9a910f0d1e490c
If you look at the top right, it says Value in USD.

Is there any any API that can help me derive this USD value irrespective of what all ERC20 tokens are in wallet?
APIs so far either need a contract address or return eth valuation
PS:

m trying to fetch all this using python's requests library
sorry for wrong tags if any


texts: Alternative for String type in smart contract and Solidity?


texts: How can I know if new transaction for this was contract generated or not?

texts:
I'm thinking I could make a kind of contract that can make serial story on blockchain(using solidity and Remix). So I want to know the way how to detect whether "someone already added a story to previous one or not" in real time at the place like Remix.

[my delusion]

1, function getPreviousStory() : returns previous story

2, function getState() : returns bool (will be false when someone is executing addStory() function and the transaction still not mined. will be true when anyone isn't executing addStory and not generating transaction)

3, function addStory(string story) : fire a Write event and send a new story if getState() returns true now. If getState() returns false, addStory() failes to avoid deprecated.


texts: Ethereum Wallet stuck pending transaction

texts:
NOOB here trying to get a handle on things.

I've been using the Ethereum Wallet from Ethereum.org for about a year.  I'm on ver 0.10.0.  Around December 2017 - January 2018 I started to have very strange issues.  I could receive Eth but I could not always send Eth.  It would take 2 or 3 attempts.  By that I mean I would configure to send some Eth and I could see the transaction in my wallet.  I could go out to Etherscan and see it "pending".  then it would disappear from my wallet with no record of the transaction and same with Etherscan.  I would recreate the send action and sometimes the second or third attempt would finally go.  I would see the transaction in my wallet and on Etherscan.

Then sometime February-March the same issue was happening but I would no longer see the completed transaction in my wallet.  Etherscan showed the transaction.  My wallet was debited the correct amount but no local transaction record.  More and more I would have try sending Ether multiple times for it to go through.

In April, no send transactions were recorded in my wallet.  Etherscan recorded them properly.  To get the send to go through I would have to recreate the transaction 4-5-6 times.

Now in May no send transactions work.  The last two sends to shapeshift seem to be stuck.  Nothing shows in my wallet, my balance hasn't changed.  Etherscan shows 1 sometimes 2 transactions that are "pending".  Other times, they are not there.  My balance still seems correct in both my wallet and Etherscan.

I have tried geth --removedb
I've tried geth --syncmode=fast --  cache=4096
I've removedb and let Ethereum Wallet sync
I've completely uninstalled Ethereum Wallet and reinstalled.

My Ethereum Wallet balance seems correct but still I have a pending transaction on Etherscan that seems to be blocking me from sending anything else.

I'm looking for ideas on how to clear this and be able to send again.


texts: web3.isConnected() returns nothing when connecting to geth with web3.js(Version 0.19.0)

texts:
web3.isConnected() has issue. When connecting to an IPC node

I think it is waiting for something because when i starting my nodejs program nothing happens,

I am running ethereum node and try to connect with my Dapp But there is some problem with my rpc connection that is web3.isConnected() is not returning anything  It should return true or false


texts: How secure is the seed phrase (12 words, 24 words)

texts:
The total number seed phrases are 1,329,227,995,784,920,000,000,000,000,000,000,000 - if I right counted - 12 words.
Yes is very much, as seems.
But let's regard - there is a thief and he wants to steal money from anybody.
I focus accent on the words from ANYBODY.
I.e. thief's target is to find the first address with money.
And that large number doesn't seem so much.
Also bad that the dictionary base is opened to everyone.
A thief can use a brute-force attack and get the first address with money.
And if we understand seed phrase include many addresses, that make the task for thief easier.
I understand the 13 or 25 words, it's created by me, and they are known by no one. It means that security is more, more, more better.
Anybody can say what number of seed phrases are used now?
Do developers of the network think about what happens later?
And need whether to think about this problem at all. Can be I see this problem in the dark.


texts:
Is it possible to organize a secret ballot voting in a smart contract

One knows the number of votes casted and who have voted
You know the total results of the voting
However, one doesn't know who voted and what


texts: why require() is checked after executing transfer()

texts:
From OpenZeppelin's ERC721 contract:
    function _safeTransfer(address from, address to, uint256 tokenId, bytes memory _data) internal virtual {
        _transfer(from, to, tokenId);
        require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
    }

In the above code, what purpose does require(...) server after _transfer() as the token will be transferred anyways? I would like to details regarding why such an approach is used.
Moreover, if to is a contract, _checkOnERC721Received returns true always. what does this signify? Is any ethereum contract compatible to hold ERC721 safely out-of-the-box, even without implement ERC721Receiver ?


texts: How do I keep my Ethereum Wallet synchronised after the initial synchronisation

texts: I have successfully installed and synchronised Ethereum Wallet and it has correctly brought in my test Ether purchase.  How do I resynchronise to ensure more current transactions are recorded on my account?


texts: Solidity - How to send ETH from my wallet to another address

texts:
I would like to programmatically send my ETH to another wallet address using Solidity.
Could you please tell me this is possile? If yes, please give me some examples.
I read the docs and it has only for created tokens.

Thanks


texts: Forgot my Ethereum Address. Still have seed phrase and private key

texts:
I got started with Ethereum using the Get Address option on https://live.ether.camp/

So I registered and got my own address. I securely saved my seed phrase and my private key, but forgot to copy my own address.

I browsed on Google a little, and found only posts about those who had lost their wallet password and stuff.

So, how I do I find out my address? Once again, I have my seed phrase and private key securely with me.


texts:
I'm writing a test for a time-dependent solidity function. I'd like to use the increaseTime.js helper from v1.12.0 of OpenZeppelin's library.

When I try to call this helper inside my test, I get an error. For small durations like 1200 (20 minutes), I get a revert error: "Uncaught Error: VM Exception while processing transaction: revert." For larger durations like 86400 (1 day), I get "VM Exception while processing transaction: invalid opcode."

import { increaseTime } from './../contracts/openzeppelin/test/helpers/increaseTime.js';

contract('Kabocha', function(accounts) {
  describe('Pumpkin', async function() {
    it("should do a time-dependent thing", async function() {
      // setup stuff goes here
      await increaseTime(86000);
    }
  }
}

Any tips for working with this helper library? Perhaps one day is too far in the future for evm_increaseTime.

I'm using Ganache CLI v6.1.6 (ganache-core: 2.1.5) as my test chain.

Update:

In my setup, there is a step that sets a timestamp and compares against block.timestamp. When I comment out everything in the setup including this line, I can call increaseTime with no limit. However, uncommenting the timestamp setter means I can only call increaseTime with a max value of 249.

Update #2

Any step involving block.timestamp followed by increaseTime causes my code to revert. Seems like the two don't mix.


texts:
I am trying to implement an algorithm requiring matrix multiplication. I know I can program this in the rudimentary way similar to doing the process by hand, but I am worried about the computational costs associated with this.

In solidity, the "matrix" would just be a two-dimensional array or even just a vector.

Does anyone know of an existing implementation of matrix multiplication in solidity? I want to make sure I do this efficiently and am wondering if anyone else has established a good way of doing it. I am unable to find any library or posts on the subject.

Thanks in advance.


texts:
Hi guys.
I have got one big problem. When i try to compile my code i'm getting some kind of unusuall error.
I think everything is ok but when i try to "node compile.js" my main file ("inbox.sol") everytime i'm getting same error:

"'inbox.sol:1:1: Parser## Heading ##Error: Expected pragma, import
directive or contract/interface/library definition.\npragma solidity
^0.5.10;\r\n^\n',"

I will past there my code and exactly what solidity complier says.
Compile.js file

Inbox.sol file

Console and error

You are my only hope guys. Please help me.


texts: How does etherchain access and query Ethereum blockchain transaction data?

texts:
Can whatever method that etherchain are using to access and query the blockchain data also be leveraged by the average web developer in a garden variety web app using a remote call? Or, are etherchain running a full node on their back end?

Is there such thing as Ethereum node hosting, such that web apps could be deployed and by way of web3.js, query transaction data and display smart contract state? Perhaps Azure's BaaS or BlockApps could be used to achieve something like this? Maybe Metamask is what I'm looking for?


texts:
I have a question about concurrency in smart contracts. For instance, I have array of structs and each struct should have a "unqiue" ID. For my needs, it is enough to have ID equal to position in array (later it can be changed, so ID must be stored in structure instance).

Is it safe to get array length to use it as ID or many transaction could be handled in the same time and get the same array length?


texts: Map Bytecode of Function to Function Within Entire Bytecode


texts: Web3.py Could not transact with/call contract function, is contract deployed correctly and chain synced?

texts:
I am trying to call a contract function deployed in Ganache. I am pretty sure the contract is deployed because I can transact() and work with other functions. But when I call() it, I get this error:

Could not transact with/call contract function, is contract deployed
correctly and chain synced?

this is my function call:
 updated_card = magic_ideas.functions.get_card('731759').call()

Previously, I have to "deploy an exam" with this code and it works correctly:
 t_hash1 = magic_ideas.functions.new_card('title', 'example_text', 'www.card.com', '731759').transact()

I get a t_hash1. Then when I try to get_card using .call() I get the error. What am I missing?
EDIT
This is the contract declaration:
magic_ideas = w3.eth.contract(address="0x246eCb1dA50199FD7FcC20Ad08C617C52e34b128", abi=abi)

The abi is a copy & paste from remix.


texts: DApp owner pays for the transaction without invoking smart contract

texts:
I am working on a chrome extension (crypto wallet) that lets you use one of our custom ERC20 token to make a purchase on websites. Most of the users of the extension don't have Ethereum in their accounts and won't be able to pay the transaction fee.

My research has yielded the following info:

We can pay transaction fee on the senders behalf in the smart contract
The user just has to sign a transaction, and we can use this signature in the smart contract to keep the validity of the transaction, while paying for the gas at the same time.
My problem however is that I don't want to do this within a smart contract as it gets me to pay extra gas.

Is there a way I can save these signed transactions on a server, and then using my host language (Javascript) and web3 make changes to the signed transaction so that gas comes from one of my accounts? Is it even possible?


texts:
What's the most efficient and trust-less way to sign a transaction through a middle-ware?

Thanks for your help.


texts:
The DAO contract was attacked on 17th June 2016 where the attacker drained about USD 50 million worth of ethers using a recursive call vulnerability in The DAO contract code.

The attacker drained the stolen ethers into a few child DAOs and the Robin Hood Group drained the remaining funds into other child DAOs.

The Ethereum blockchain was hard-forked in block #1,920,000 on 20th July 2016 to transfer the ethers from The DAO contract and it's child DAOs into a WithdrawDAO contract.

While the majority of Ethereum nodes clients are running the hard-forked blockchain (ETH), a minority of Ethereum nodes clients are running the non-hard-forked Classic blockchain (ETC).

Ethereum node clients can be configured to use the hard-forked blockchain or the non-hard-forked blockchain. Some nodes have been configured to relay the transactions from the hard-forked blockchain to the non-hard-forked blockchain, and vice versa. Transactions executed on the ETH blockchain have a high likelihood of being replayed on the ETC blockchain, and transactions on the ETC blockchain have a high likelihood of being replayed on the ETH blockchain.

Several split contracts have been deployed at the same contract address on both the hard-forked and non-hard-forked blockchains.

How do you use these split contracts to conditionally send ethers to another accounts in either the hard-forked ETH chain or the non-hard-forked ETC Classic chain?

The DAO Refunds

How do I convert my The DAO tokens into ethers using the withdrawal contract after the hard fork?
How do I get a refund for the amount I paid in excess of 1 ether to 100 The DAO tokens
How do I get a refund for my The DAO tokens that was split into a child DAO?
How do I convert my The DAO tokens into ethers on the Ethereum Classic chain?
[THIS] How to conditionally send ethers to another account post-hard-fork to protect yourself from replay attacks


texts: Display the amount of ERC-20 token to be spent on a function call

texts:
I am relatively new to Solidity programming, although I have a strong basis in procedural and OOP programming.
I have a small ERC-20 token which I am developing for fun. The contract contains a function which requires 1 input parameter (uint256 amount of tokens). When using Remix to call this function, Metamask pops up and asks for confirmation, but unlike the Transfer(to, amount) function, I don't get to see how much of my ERC-20 tokens I will spend.
Is there a way to make the Metamask wallet display the amount to be spent, from my code, without calling the Transfer function from my custom function?
To further elaborate just in case someone didn't get the question, when I send my ERC-20 to a friend, from Remix, Metamask pops up and displays the amount of ERC-20 token which I typed into the Remix  UI. This way, I know exactly how much I am going to send. But with this other function, it does not. I wanna change that.


texts: where to host express api that communicates with smart contract to be fully decentralised?

texts: I need to host  express api that communicates with smart contract to be fully decentralised. Any to host it decentralised.


texts: What datatype should I use for an IPFS address hash?

texts:
Here is an IPFS hash: QmTfCejgo2wTwqnDJs8Lu1pCNeCrCDuE4GAwkna93zdd7d. According to IPFS docs, they are base58 encoded, and I assume the Qm is metadata (because they all share this).

What is the most effective datatype to store one of these?

Edit: they do not all start with Qm


texts:
I have a simple question.

Should I let my server always open inbound connections when using Geth?

I want to keep my server secure by restricting inbound connections. Is there a way to use Geth only with outbound connection like Bittorrent? If there is, could you let me know what ports I have to open for it?


texts: How to generate signature & validate signature offline w/o using web3

texts:
I just need a simple way to sign a message offline, preferably using Python or JavaScript.
I don't want to have to sign in using Web3. I just want my private key to be used from a variable in the code.

This is only for a proof of concept tool that I'm making, which is why I don't want to use Web3 or any nodes to do this. Is there such a library that will let me sign & verify a message the same way an Ethereum nodes would?


texts: Sending value with transaction using Metamask and Browser-Solidity

texts:
Using browser-solidity in combination with metamask I am testing a new contract on testnet https://testnet.etherscan.io/address/0xc03db39c18b6056f8c3a3a5495a1e11f3ff8885a but when trying to call refillFunds() method:

/* Refill SC funds to feed faucet requests */
function refillFunds() payable returns (uint256) {
    calledRefillFunds(msg.sender, timestamp(), msg.value); // Log

    return 1;
}

I got this screen to perform a transaction

but there is no option (or I cannot find where it is) to transfer 1 ether for example. The only option seems to be to transfer 0 ethers and pay the fees.

Any reason why I cannot send non-zero value with metamask interface in this transaction? Thx!


texts: MEW wallet to wallet transfer not arrived

texts:
I have sent ETH from one my ether wallets to another; this is the TX: 0xfd1f16c53057a5c8bca535d088b3976068869bdc676d45a47d324cd6a7b24dfe at Etherscan where the status reports 'success'however my balance still shows zero.
Can someone please advise what i need to do?
Thanks


texts: Require not working properly, always lead to an error

texts:
There is a login page and register page in my dapp based on refer and earn concept to authenticate and authorize user respectively..Login part is working fine, but when I try to register a new account into blockchain with 0.05 ether fees, metamask pops up and shows ALERT: Transaction Error. Exception thrown in contract code..When I check on etherscan, I got User already exists error instead.No matter which address I use, the error remain same.
 uint public lastUserId = 2;

 struct User {
    uint id;
    address referrer;
    uint partnerCount;
    bool isRegistered;
}

//function isUserExists(address _userAddress) public view returns(bool){
    //   return users[_userAddress].id != 0;
    //}

 function userRegisteration(address _userAddress, address _referAddress) private returns(bool) {
    require(msg.value == 0.05 ether, 'registeration cost 0.05');
    // require(!isUserExists(_userAddress), "User already exists");
    // require(isUserExists(_referAddress), "Referrer doesn't exist");

    require(!users[_userAddress].isRegistered, "User already exists"); //The error I got
    require(users[_userAddress].isRegistered, "Referrer doesn't exist");

    User memory user = User({
        id: lastUserId,
        referrer: _referAddress,
        partnerCount: 0,
        isRegistered: true
    });

    users[_userAddress] = user;
    users[_userAddress].referrer = _referAddress;
    users[_referAddress].partnerCount++;
    lastUserId++;

    emit registerSuccess(_userAddress, _referAddress);
    return true
}

function registeration(address _referAddress) external payable {
    userRegisteration(msg.sender, _referAddress);
}

Web3js
 contract.registeration(
        $("#refer_id").val(),
        { value: web3.toWei(0.05), gasPrice: 98e9 },
        function (err, res) {
          if (err) {
            console.log(err.message);
            $(".tx").show();
            $(".transaction_err").text(err.message);
            return false;
          }
        });

)
The response I got in the console is
  Transaction has been reverted by the EVM:
{
  "blockHash": "0x8338fb44f94cef337879b07ebf8251f99b3c6238489e0c2e10d903cf921a0d1c",
  "blockNumber": 7427013,
  "contractAddress": null,
  "cumulativeGasUsed": 22838,
  "from": "0x8a9bbe43c28a82596f7ae4cff80377a7c8e0c25c",
  "gasUsed": 22838,
  "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
  "status": false,
  "to": "0x2d99d6db85b012bdd3ced1c21fc025847c6c2694",
  "transactionHash": "0x07e03803ede8a172db5cbe27f3aafead9668af0a6e9fbe7804802b1bf0c5a6b4",
  "transactionIndex": 0,
  "events": {}
}


texts: For example, the smallest amount of Bitcoin is one Satoshi or 0.00000001 BTC. What is the smallest amount of Ether and what is it called?


texts: Easy way to get all token transactions of an ethereum token holder?

texts:
On etherscan.io I can download the last 2000 erc20 token transactions of a specific token holder as csv.

How can I get all erc20 token transactions of a token holder?

I'd prefer a web service or a website that lets me download manually, but if it has to be I am able to set up a development environment.


texts: Why is it important to set a tokens issue number cap during the crowdsale?

texts:
Reading different white-papers I'm now a bit confused.

Some good projects use the soft cap and hard cap to limit the number of tokens issued during the crowdsale. Sometimes it's not.

More tokens means more money for the project, so why is it counterproductive to have too many tokens to issue?


texts: How can a "for-friends-only" token be traded with other currencies?

texts:
I'll start by saying that I'm a newbie. I'm learning Solidity and how Smart Contracts work.  What I would like to do is simple: I would like to sell MyFriendToken (MFT) to friends only, in exchange for some ETH (1 ETH = 1000 MFT), and then allow them to trade this token with other currencies or other tokens (maybe through EtherDelta).

Here is the simple contract about to my two questions (further below) refer:

pragma solidity ^0.4.0;
contract ERC20 {
    //here are the same functions defined in the TokenContractFragment
    //https://theethereum.wiki/w/index.php/ERC20_Token_Standard

    function balanceOf(address _owner) constant returns (uint balance);
    function transfer(address _to, uint _value) returns (bool success);
    function transferFrom(address _from, address _to, uint _value) returns (bool success);
    function approve(address _spender, uint _value) returns (bool success);
    function allowance(address _owner, address _spender) constant returns (uint remaining);
    event Transfer(address indexed _from, address indexed _to, uint _value);
    event Approval(address indexed _owner, address indexed _spender, uint _value);
    uint public totalSupply = 0;
    mapping(address => uint256) balances;
}

contract MyFriendToken is ERC20{
    string public token_name;
    string public symbol;
    uint8 public decimals;

    address public owner;

    bool purchase_OK = true;

    address friend1 = address(0x123...);
    address friend2 = address(0x456...);
    //.....

    function purchase_ko() {
        if(msg.sender != owner){ throw;}
        purchase_OK = false;
    }

    function purchase_ok()  {
        if(msg.sender != owner){ throw;}
        purchase_OK = true;
    }

    function MyFriendToken(){

        owner = msg.sender;
        token_name = "MyFriendToken";
        symbol = "MFT";
        decimals = 18;
    }

    function kill() {
        if (msg.sender == owner) selfdestruct(owner);
    }

    function() payable {
        if(!purchase_OK){throw;}
        if(msg.sender != friend1 && msg.sender != friend2) {throw;}

        owner.transfer(msg.value);
        uint256 myFriendToken = (msg.value * 1000);
        totalSupply += myFriendToken;
        balances[msg.sender] += myFriendToken;
    }
}

Here are my questions:

1) When the purchase ends, can my friends exchange this token on EtherDelta, for instance?

2) If I call the kill() function, will all the balance of my friends be lost?

Many thanks. If this question is too broad or if this isn't the right place, I'll delete without problem.


texts: Can I call one function that not declared in the interface but implemented in the contract?

texts:
Example:
interface IA {
    function a1(uint256) public returns();
}

import "./IA.sol";

contract A is IA {
    function a1(uint256 _a1) public returns() {
        _a = 1;
    }

    function a2(uint256 _a2) public returns() {
        _a2 = 2;
    }
}

import "./IA.sol";

contract B {
    IA a;
    function b(address _aAddress, uint256 _a2) public returns(uint256) {
        a = IA(_aAddress);
        a.a2(_a2);
        return _a2;
    }
}

Question:
When I try to interact with a contract by using interface(contractAddress), can I call one function that not declared in the interface but implemented in the contract?
For example, Can I call the a2() of contract A in the contract B in this way?


texts:
I deployed a contract on JavaScript VM using remix online IDE.  Here is the contract:

pragma solidity ^0.4.17;

contract FileDetail {
 struct File{
    string fileName;
    string fileHash;
 }

 File[] private files;

 function setFile(string fName, string fileHash) public{
 File memory file = File({fileName:fName,fileHash:fileHash});
  files.push(file);
 }

 function getFile(uint256 index) external view returns(
 string fileName,
 string fileHash

 ){

   File memory file = files[index];
   fileName = file.fileName;
   fileHash = file.fileHash;

 }
}

On JavaScript VM the contract gets deployed and the set and get methods works fine. But when I try to deploy the same contract, it first opens metamask and after clicking submit it says:

creation of FileDetail pending

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

Its been an hour. I also unlocked the account using eth on localhost. My ropsten node logs shows the following:

INFO [08-01|14:15:33.141] Submitted contract creation fullhash=0x66a2c43405387e9df8d7f406e7b0d755b55930faf4f3da9d92621a2bbe31417e contract=0x157d49aA855bf99f025f9f9eF8B45Be9a237bD5B


texts: Which is the correct spot to put destination address?

texts:
pragma solidity 0.4.21;

contract Forwarder {

  address public destinationAddress;
  event LogForwarded(address indexed sender, uint amount);
  event LogFlushed(address indexed sender, uint amount);

  function Forwarder() public {
    destinationAddress = msg.sender;
  }

  function() payable public {
    emit LogForwarded(msg.sender, msg.value);
    destinationAddress.transfer(msg.value);
  }

  function flush() public {
    emit LogFlushed(msg.sender, address(this).balance);
    destinationAddress.transfer(address(this).balance);
  }

}

Please just say the spot by replying HERE1 or HERE2 blah blah as it's on the script above.

for example, my destination address where I want all eth on contract to be forwarded to is 0x7e0fE0Bd87F84906bc19438fb5F932e189Dd127e, where do I put it on the script?


texts: Read Write restrictions in private blockchain

texts:
How to create admin node in private blockchain?
How to give read write permission in private blockchain?


texts: How do I send funds from a contract to an account using bytecode?

texts: The instruction CREATE will send funds to a new account. Is there another instruction for sending funds to an account that already exists? Or I just have to use CREATE as if the account doesn't exist?


texts: Recently upgraded Solc and Web3. Transactions with zero addresses now reverting with "invalid address" message?

texts:
I recently upgraded Web3JS and Solc.  Now every time I pass a zero address to a Solidity contact method the transaction reverts with an "invalid address" message.  This message appears to be coming directly from the EVM since I don't have that message in any of my revert error strings.  The error message includes the name of the parameter that the EVM thinks is invalid so I'm sure it's from the EVM (_bandAddr).  This is from the method:

function payBand(address payable _bandAddr)

You can see that parameter in the error message:

invalid address (arg=\"_bandAddr\", coderType=\"address\", value=0)

I have tried passing "0" and "0x0" and still get that error.  Has anybody else seen this and has a fix for it?  Before upgrading I could simply pass "0" and would not get that error.

Ganache CLI v6.2.3
    using Ganache Core 2.3.1
Truffle 5.x beta
Web3 v1.0.0.0-beta.37
Solc v0.5.0


texts: Unable to change contract data with nodejs (web3)

texts:
I created a contract, and deployed it into my private blockchain,
as you can see I use mapping and dynamically allocated array.
When I am trying to add a domain by 'addDomain' method with remix web ide it works fine, by when I am trying to use 'addDomain' method with nodejs its return an address(Big Number) as return value, but actually, when I use 'getDoamin' its seems that the transaction is not approved or something like this.

Reputation.sol

pragma solidity ^0.4.0;

contract addressRecord {
    struct  Record {
        address owner;
        uint score;
    }

    mapping (string => Record) records;
    string[] records_arr;

    function addDomain(string _domain, uint _score) {
        if (records[_domain].owner != address(0x0)
        && records[_domain].owner != msg.sender) { return; }

        records[_domain] = Record(msg.sender, _score);
        records_arr.length += 1;
        records_arr[records_arr.length-1] = _domain;
    }

    function getDomain(string _domain) constant returns(uint) {
        return records[_domain].score;
    }

    function changeScore(string _domain, address _to) {
        require(records[_domain].owner == msg.sender);
        records[_domain].owner = _to;
    }

    function domainsCount() constant returns (uint) {
        return records_arr.length;
    }
}

reputation.js

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

const abi = require('./abi.json');
const contractAbi = web3.eth.contract(abi);

const contractAddr = "0x0014b44b785769e28b5cb097c1329784c96333f6"; // replace this
const walletAddr = "0xca1c9203f10f9b918d8630a540d85456dfb8b760";   // replace this

const myContract = contractAbi.at(contractAddr);

web3.personal.unlockAccount(walletAddr, "12345678");
var myArgs = process.argv.slice(2);
console.log(myArgs[0]);
console.log(parseInt(myArgs[1], 10));
console.log(myContract.addDomain(myArgs[0], parseInt(myArgs[1], 10), { from: walletAddr, to: contractAddr }));
console.log(myContract.getDomain(myArgs[0], {from: walletAddr, to: contractAddr}));

Nodejs output

testdomain.com
50
0x11229d6545a7002cbda9f102d91e010f9d990a149072382fe86dc63b1f6b639d
{ [String: '0'] s: 1, e: 0, c: [ 0 ] }

Geth log

INFO [09-03|00:50:32] Submitted transaction                    fullhash=0x73b720ccfb3811db2339a060655341bf07ad778e7dd9a6e160b868c647b0120a recipient=0x0014b44b785769e28b5cb097c1329784c96333f6
INFO [09-03|00:50:36] Successfully sealed new block            number=4851 hash=3bbc5a…d972af
INFO [09-03|00:50:36]  block reached canonical chain          number=4846 hash=4d78df…ca4938
INFO [09-03|00:50:36]  mined potential block                  number=4851 hash=3bbc5a…d972af
INFO [09-03|00:50:36] Commit new mining work                   number=4852 txs=1 uncles=0 elapsed=486.898µs


texts: Transactions on Ethereum private network using the MetaMask Ropsten test connection?

texts:
I have 4 accounts on my private blockchain ethereum network and one of the account has balance of 10000000000000000000 and other accounts have zero balance each.

When I connect to this network from MetaMask, using Ropsten Test network, should the same balance from private ethereum network be reflected in the MetaMask wallet having same number of accounts from my private ethereum network. And can i transact between these accounts (from account1 to account2, as these are created using commands on server) using the MetaMask wallet?

If i create the new account on metamask, should that account be reflected on my private ethereum network?

How should i transfer my existing balance from one account to other?

Regards,
Jagdish


texts: Factory contract failing to create - Mix

texts:
I'm trying to implement factory contracts in Mix but can't get the child to create and return an address.
I deploy Factory but when I try to call the creator function,

contracts['Factory'].contract.Create(10)

Mix throws:

JavaScript  error   14:18:06    web3.js - line 3881 - Uncaught invalid address

contract Gizmo
{
    int public value;
    function Gizmo(int v) {
        value = v;
    }
}

contract Factory
{
    address gizmoAddr;
    function Create(int _value) returns (address) {
        gizmoAddr = new Gizmo(_value);
        return gizmoAddr;
    }
}


texts: Go can't find common and types package when building Geth client node project?

texts:
I am trying to build the Ethereum Geth client node on an Ubuntu 14.04 LTS box.  I am using the 2017.3 Goland client.  When I try to compile the project I get the errors below:

interfaces.go:25:2: cannot find package "github.com/ethereum/go-ethereum/common" in any of:
    /usr/local/go/src/github.com/ethereum/go-ethereum/common (from $GOROOT)
    /home/robert/go/src/github.com/ethereum/go-ethereum/common (from $GOPATH)
interfaces.go:26:2: cannot find package "github.com/ethereum/go-ethereum/core/types" in any of:
    /usr/local/go/src/github.com/ethereum/go-ethereum/core/types (from $GOROOT)
    /home/robert/go/src/github.com/ethereum/go-ethereum/core/types
(from $GOPATH)

I have checked my GOPATH which has go-ethereum as its root.  I do see a common directory underneath it but not types directory.  I checked the Geth repo on GitHub:

https://github.com/ethereum

And I don't see a sibling common or types project.  Does anyone know how to fix this problem?


texts: I logged onto my ethereum classic wallet and the balance is zero. This is absolutely wrong. What do I need to do.


texts: Geth: Checkpoint challenge timed out, dropping

texts:
I get a warning in Geth that I was not able to find any information on:

Checkpoint challenge timed out, dropping

What does this mean?


texts: Do view functions cause reentrancy vulnerabulity?

texts:
It's well known that calling an external function before changing something in the contract causes a security problem called "reentrancy vulnerability".
Does calling an external function through a view member of an interface cause reentrancy vulnerability?


texts:
is there any simple to get console.log in remix.ethereum.org?
            if (invest.lastCollectedTime < invest.baseTime){
               console.log("test");
            }

In remix console works if type in textbox


texts:
This question was asked on Reddit a while ago:

  Where is the state data actually stored though? On the hard drive of each node? Separate from or within the blockchain?
  — Reddit: Basic Questions About the Ethereum EVM and State Storage


texts: What are geopolitical risks to blockchain consensus?

texts:
Would quantum computing eventually enable you to take over the consensus mechanism on the blockchain?
Do countries with cheap electricity, cold climate, and high internet bandwidth (e.g. Iceland or Norway with geothermal or hydroelectric power, low average temperature, and modern internet infrastructure) have an unfair advantage over equatorial countries?
Would corporations who have control over backbone bandwidth (especially without net neutrality protection) be able to impose embargo against countries as a military weapon?
These questions become more significant in a future when blockchain technology disrupts finance, contracts and all other applications of blockchain.


texts: Noob Question About Pool Mining & Wallets

texts:
I'm sure this is a stupid question; but please be gentle, I am still learning the basics.

Some Background:

I have a rig I purchased from a 3rd party that mines ETH using MiningPoolHub.com. It collects all the mined coins and displays them under my dashboard page on MiningPoolHub.com. Once it hits a specific threshold (that I set) it transfers the coins to coinbase wallet account. I have this address set on the wallet page of MiningPoolHub.com. This all works fine. As an educational exercise I have decided to build my own rig and mine using this same pool. It's built, running Xubuntu, and the etherium software has been installed.

The Question:

Here is where I am stuck. All of the tutorials and information I can find online seem to say the next step is to create a wallet where the coins will be deposited to. However this doesn't seem correct to me because my current setup leaves the coins in my MiningPoolHub.com account and THEN transfers them to my existing wallet with coinbase. Could someone please point me in the right direction of the next step I need to take?

Thank you for your time.


texts: check msg.data in crowdsale contract, but the msg.data.length is zero

texts:
pragma solidity ^0.4.18;

import 'zeppelin-solidity/contracts/math/SafeMath.sol';
import 'zeppelin-solidity/contracts/token/ERC20/ERC20.sol';

import '../util/BytesLib.sol';

contract Crowdsale {
    using SafeMath for uint256;
    using BytesLib for bytes;

    // Address where funds are collected
    address public wallet;

    ERC20 public token;

    // Amount of wei raised
    uint256 public weiRaised;

    function Crowdsale(address _wallet, ERC20 _token) public {
        require(_wallet != address(0));

        wallet = _wallet;
        token = _token;
    }

    function () external payable {
        buyTokens(msg.sender);
    }

    function buyTokens(address _beneficiary) public payable {

        bytes memory msgData = msg.data;
        bytes memory dataValue = msgData.slice(36, 32);
        uint256 weiAmount = dataValue.toUint(0);

        weiRaised = weiRaised.add(weiAmount);
      }
}

when I transfer my ERC20 tokens(not Ether) to the contract, the msg.data.length is always zero. However, in dev environment, when I assign a value to the msg.data below, the parameter weiAmount get the correct number as expected.

bytes msgData =  '0xa9059cbb0000000000000000000000007d052a29e0cf3b046e0618df7bed3423725619df0000000000000000000000000000000000000000000000000de0b6b3a7640000'.

ps: BytesLib.sol is used to slice the bytes, see this link https://github.com/GNSPS/solidity-bytes-utils/blob/master/contracts/BytesLib.sol


texts:
Using the Truffle console, I'm able to obtain the address of a deployed smart contract by issuing the following:
MySmartContract.deployed().address;
In this case, MySmartContract is a smart contract written in Solidity and is compiled and migrated with Truffle to TestRPC.
Now, using the Web3-library, I'm able to obtain a 'reference' to the deployed smart contract by issuing the following statements:
web3.eth.contract(MySmartContract.abi).at("0xf6cd8e7179c88aae52339b5268fd67ea2d3305b9")
...but obviously, I want to treat and access the smart contract like a singleton.
How do I obtain the address for a deployed (singleton) smart contract without having to specify its address?
Update:
While I have seen the term being used in blogs and tutorials, 'singleton' does indeed not cover it exactly; especially considering the fact that, if you upgrade a smart contract, its actually deployed to a different address. (Just trying to verify my understanding of things here; correct me if I'm wrong!)
But how exactly does Truffle know what contract I'm referring to with MySmartContract.deployed()?
Basically, I want to tell web3: "Here is my contract ABI, find me its address on the blockchain!"


texts: Could not find a declaration file for module 'solc''

texts:
I have installed solc without any errors or warning, but when i am trying to run node compile.js command in cmd then i am getting following error

On checking the code, i found that "const solc = require('solc');" is returning an error which says

Could not find a declaration file for module 'solc'.

Please help, i am stuck on very first and basic step.


texts: How do you calculate a wallet balance in the world of shards?

texts: I have a general question about calculating account balances in the new world of sharding.  In the Bitcoin blockchain, in order to accurately calculate someone's wallet balance, you have to analyze every transaction in the blockchain (correct me if I'm wrong on this as it's the basis for my next question).  So in Ethereum does sharding impede the effort of trying to calculate someone's wallet balance because instead of going to a single node to analyze the entire blockchain, you have to traverse the blockchain as its spread out over hundreds of nodes where each shard lives?


texts:
What is the best practice for concatenting arrays in Solidity?

I have this (which compiles):

contract Concatenator {
    address[]  Accounts1;
    function ConcatenateArrays(address[] Accounts2){
        uint i = 0;
        while (i++ < Accounts2.length) {
            Accounts1.push(Accounts2[i]);
        }
    }
}

I have a feeling that there might be a better way of doing it, however. Hence this question.

Also, I noticed that, if I pass the 2 arrays to the function, I get a memory error. Why can't I pass the two arrays directly to the fucntion?


texts: Ethereum's Storage: is SSTORE updates only at the post-transaction state?

texts:
I'm trying to figure out from Ethereum's yellow paper (Homestead edition) how does its storage model works (NOT memory model).

It seems that the storage is updated only once, after a transaction is over.

Specifically, SSTORE updates σ' (the post-transaction state in the yellow's paper notation), and SLOAD loads from σ (the pre-transaction state).

If that's true, then this pseudo-OPCODE:

SLOAD(1)

would act the same as:

SSTORE(1,"question")
SLOAD(1)
SSTORE(1,"another question")
SLOAD(1)

Did I get it right? Is there a way to update the storage during a transaction (using it as a RAM)?


texts: How to use smart contract setters from JS Console?

texts:
I'm having accessing my smart contracts' setters from console using a simple HTML / JS website. I'm able to access public variables and getters, but when trying to use my setters from console it throws an "invalid address" error.

Some google'ing told most of the time the reason for this problem is not having set an default address, but I did this in my JS script (web3.eth.DefaultAccount = web3.eth.accounts[0];). Is there something else I've missed?

I'm using the Remix IDE for writing / publishing the smart contracts and connect to my locally hosted testRPC network. I'm trying to use my setter by entering Contract.setter("test") in the console.

error:

web3.min.js:2 Uncaught Error: invalid address
    at v (web3.min.js:2)
    at l (web3.min.js:2)
    at web3.min.js:2
    at Array.map (<anonymous>)
    at i.formatInput (web3.min.js:2)
    at i.toPayload (web3.min.js:2)
    at r.e [as sendTransaction] (web3.min.js:2)
    at c.sendTransaction (web3.min.js:2)
    at c.execute (web3.min.js:2)
    at <anonymous>:1:10

Smart contract:

pragma solidity ^0.4.4;

contract c {
    string test;

    function setter(string _s) {
        test = _s;
    }

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

HTML / JS page:

testpage


texts: Expected primary expression error in pragma solidity ^0.8.0

texts:
I am trying to use any of the uint to string function implementations from the below links.
How to convert uint to string in solidity?
How to convert string to int
Conversion of uint to string
However in pragma solidity ^0.8.0 the compiler show the following error:
ParserError: Expected primary expression.
Is there a workaround?
This implementation for example produces that error
function uintToString(uint v) public returns (string memory) {
    uint maxlength = 100;
    bytes memory reversed = new bytes(maxlength);
    uint i = 0;
    while (v != 0) {
        uint remainder = v % 10;
        v = v / 10;
        reversed[i++] = byte(48 + remainder);
    }
    bytes memory s = new bytes(i); // i + 1 is inefficient
    for (uint j = 0; j < i; j++) {
        s[j] = reversed[i - j - 1]; // to avoid the off-by-one error
    }
    string memory str = string(s);  // memory isn't implicitly convertible to storage
    return str;
}


texts: Can the v2 keystore json file for Ethereum wallet be converted to v3

texts: If someone has an Ethereum ICO keystore Json file like this pics, is it possible to convert it to the v3?


texts: Miss aligned state loading/storing gas costs

texts:
For a smart contract idea that spins around in my head, I have the situation where I have to conserve the old values of a variable (no storage refund or cheaper SSTORE updates). As the value I write is comparatively big I wanted to estimate the gas cost that will occur and I realized that it would be cheaper to each time create a new contract with the data as code and then read it over EXTCODECOPY instead of using SSTORE and SLOAD.

A CREATE costs according to the yellow paper 32000 + 6400 per word (200 per byte), whereas an SSTORE costs 20000 per Word. in the CREATE case another 20000 are needed to store the address, so already with 4+ words stored the contract creation is cheaper.

An EXTCODECOPY costs 700 + 3 per Word (+200 to load the address with LOAD), whereas the SLOAD costs 200 per word. Here we need 5+ words for the contract creation to be cheaper.

I'm interested in the reason behind this, why is the intended way more expensive than a way where we misuse the CREATE opcode. Is one of the two ways underpriced or overpriced?

Even if in cases where the updating SSTORE (cost 5000 instead of 20000) is used it would still be beneficial in the cases where we update rarely in comparison to the expected reads.


texts: Solidity Invalid implicit conversion from string memory to bytes memory requested

texts:
pragma solidity ^0.5

contract ProofOfExistence {

    // ... some code here

    function proofFor(string memory document) public view returns(bytes32) {
        return sha256(document);
    }

    // ... some more code here
}

Gives following error :

  TypeError: Invalid type for argument in function call. Invalid
  implicit conversion from string memory to bytes memory requested.

I am unable to understand why this error is coming.

UPDATE :

pragma solidity ^0.5;
// Proof of Existence contract, version 3
contract ProofOfExistence3 {
  mapping (bytes32 => bool) private proofs;
  // store a proof of existence in the contract state
  function storeProof(bytes32 proof)  public{
    proofs[proof] = true;
  }
  // calculate and store the proof for a document
  function notarize(string memory document) public {
   **bytes32 proof = proofFor(document);**
    storeProof(proof);
  }
  // helper function to get a document's sha256
  function proofFor(bytes memory document) public pure returns (bytes32)  {
    return sha256(document);
  }
  // check if a document has been notarized
  function checkDocument(string memory document) view public returns (bool) {
    **bytes32 proof = proofFor(document);**
    return hasProof(proof);
  }
  // returns true if proof is stored
  function hasProof(bytes32 proof) view public returns(bool) {
    return proofs[proof];

UPDATE ERROR After the update as suggested I am getting the same error but on the lines having ** ...** this time. Why is it coming now?
Thanks


texts: Is it possible to get the exact amount of Ethers deducted in a 'simple' send?

texts:
I can specify a gas price and a gas limit. These give me the maximum values.
I need to be able to compute the exact amount that is going to be deducted when I do a simple send (EOA to EOA transfers).

Is that possible?
In Bitcoin, I can specify the exact fee I need to pay. I know Ethereum is not Bitcoin but at least for simple sends as above, this should be possible.


texts: How to return balance of smart contract for particular address in solidity?

texts:
I want to create a function which will accept address as argument and return balance of smart contract here is what i

function get_balance(address _add)
 {
     balance = balanceOf[_add];
     return balance;

 }

But it giving me following

 Different number of arguments in return statement than in returns declaration.
     return balance;

Please let me where i am wrong or is there any other way to return balance

Here is full code of contract

pragma solidity ^0.4.6;
  contract tokenRecipient { function receiveApproval(address _from,    uint256 _value, address _token, bytes _extraData); }
 contract RUBY {
 string public standard = 'RUBY 1.0';
 string public name;
 string public symbol;
 uint8 public decimals;
 uint256 public totalSupply;
 uint256 public balance;
 address public owner;
 mapping (address => uint256) public balanceOf;
 mapping (address => mapping (address => uint256)) public allowance;
 event Transfer(address indexed from, address indexed to, uint256 value);
 function RUBY() {
     balanceOf[msg.sender] = 10000;
     totalSupply = 10000;
     name = 'RUBY';
     symbol = 'RUBY';
     decimals = 8;
     owner=msg.sender;
 }
 modifier onlyOwner {
     if (msg.sender != owner) throw;
     _;
 }
function getBalance(address _addr) constant returns(uint) {
   return _addr.balance;
}

 function transfer(address _to, uint256 _value) {
     if (_to == 0x0) throw;
     if (balanceOf[msg.sender] < _value) throw;
     if (balanceOf[_to] + _value < balanceOf[_to]) throw;
     balanceOf[msg.sender] -= _value;
     balanceOf[_to] += _value;
     Transfer(msg.sender, _to, _value);
 }
 function approve(address _spender, uint256 _value)
 returns (bool success) {
     allowance[msg.sender][_spender] = _value;
     return true;
 }
 function approveAndCall(address _spender, uint256 _value, bytes _extraData)
     returns (bool success) {
         tokenRecipient spender = tokenRecipient(_spender);
         if (approve(_spender, _value)) {
         spender.receiveApproval(msg.sender, _value, this, _extraData);
         return true;
     }
 }
 function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {
     if (_to == 0x0) throw;
     if (balanceOf[_from] < _value) throw;
     if (balanceOf[_to] + _value < balanceOf[_to]) throw;
     if (_value > allowance[_from][msg.sender]) throw;
     balanceOf[_from] -= _value;
     balanceOf[_to] += _value;
     allowance[_from][msg.sender] -= _value;
    Transfer(_from, _to, _value);
     return true;
 }
}


texts:
I have a mapping with the key as an address and the value as  an array of addresses. How do I return the array of addresses? In older solidity versions it works. In newer compiler versions I have to declare memory. Is this producing the problem in my example? Is there a workaround for? Here is a code snippet:

mapping(address => address[]) wallets;

    function getWallets(address _user)
        public
        view
        returns(address[] memory)
    {
        return wallets[_user];
    }


texts: Send function transaction to existing smart contract using web3j

texts:
I've been exploring web3j and got the credentials working so I'm able to send transactions from an ethereum address.
Now I want to send a transaction to an already existing smart contract and use a function in the smart contract. I've been trying to find a way to do this in the documentation and online but haven't had any luck with it.

How to sent a transaction to an already existing smart contract address and use a function / method in the smart contract?