texts: Error: project ID does not have access to archive state

texts:
I am coding a script to deploy smart contracts using python web3, and I came across this error when I ran the script:
ValueError: {'message': 'Returned error: project ID does not have access to archive state', 'code': -32000, 'data': {'stack': 'Error: Returned error: project ID does not have access to archive state\n    at Object.ErrorResponse (C:\\Users\\USR1337\\AppData\\Roaming\\npm\\node_modules\\ganache-cli\\build\\ganache-core.node.cli.js:55:2110625)\n    at a (C:\\Users\\USR1337\\AppData\\Roaming\\npm\\node_modules\\ganache-cli\\build\\ganache-core.node.cli.js:55:2108932)\n    at C:\\Users\\USR1337\\AppData\\Roaming\\npm\\node_modules\\ganache-cli\\build\\ganache-core.node.cli.js:55:2093154\n    at processTicksAndRejections (internal/process/task_queues.js:93:5)', 'name': 'Error'}}

deploy.py :
from smart_contracts.solc_compile import compile_contract
from web3 import Web3
import json

# compilation process

compiler = "solc0.8.0.exe"
path = "contracts/"
contract = "inbox.sol"
to = "compiled/"

[abi_path, bytecode_path] = compile_contract(compiler=compiler, path=path, contract=contract, to=to)
with open(abi_path, 'r') as abi_p:
    abi = json.loads(abi_p.read())
    print(abi)
with open(bytecode_path, 'r') as bytecode_p:
    bytecode = bytecode_p.read()
    print(bytecode)

# initialize web3 instance
w3 = Web3(Web3.HTTPProvider('http://127.0.0.1:8545'))

# initialize hdwallet (used later for calling contracts with non-view functions
w3.eth.account.enable_unaudited_hdwallet_features()
# wallet = w3.eth.account.from_mnemonic(config['SEED'])

# test wallet - needs to be changed each time I set up ganache-cli
# NOT REAL ETH ACCOUNT
wallet = w3.eth.account.from_key("0xe7204334c48885bfce786af6b2532ae445f9bcac249f7080363d86e6356064b7")
w3.eth.defaultAccount = wallet.address

print(w3.eth.getBalance(wallet.address))

contract_skeleton = w3.eth.contract(abi=abi, bytecode=bytecode)
tx_hash = contract_skeleton.constructor('HI').transact()
tx_receipt = w3.eth.waitForTransactionReceipt(tx_hash)

contract_reference = w3.eth.contract(
    address=tx_receipt.contractAddress,
    abi=abi
)

print("Contract Address: " + tx_receipt.contractAddress)
print("Account Balance: " + w3.eth.getBalance(wallet.address))

solc_compile.py:
import subprocess

# compiler should be "solc0.8.0.exe", path should be contracts/, and contract the basename of the contract file
# after compilation returns the file location of the abi and of the binary
def compile_contract(compiler, contract, path, to):
    subprocess.call('{compiler} -o {to} --abi --bin --overwrite {contract}'
                    .format(compiler=compiler, path=path, contract=path + contract, to=to), shell=True)
    return [to + contract.rsplit('.', 1)[0] + '.abi', to + contract.rsplit('.', 1)[0] + '.bin']

# Example: output => ['compiled/inbox.abi', 'compiled/inbox.bin']
# compile_contract("solc0.8.0.exe", "contracts/", "inbox.sol")

I'm using ganache-cli for my test network and I have forked the mainnet through an infura node, and for the most part it seemed to work and my account does have ether. What does this error mean and how do I fix it?
Edit: I have since closed my project and the test-netwrok, and I opened it again and suddenly the code worked (except the last line because I forgot to convert from wei to string, but that wasn't the issue)
I would still like to hear if someone has a clue why I got that error before


texts: Use injected metamask inside of an ionic app

texts: Ive seen this topic mentioned on the ethers of stack exchange before and mostly these questions go unanswered but being that ionic is basically a fancy webview I am wondering if anyone has managed to implemented injected web3 using it


texts: Is there some possibility to listen MakerDAO's LogNote events?

texts:
I wonder is there some possibility to listen MakerDAO's LogNote events, like we able to do with standard events.
What I managed to research:
I saw that LogNote was listed as an event from contract details
let contractIntanse = await new web3.eth.Contract(abi, contractAddress);
console.log("contractIntanse.events: ", contractIntanse.events)

contractIntanse.events:  {
  Approval: [Function: bound ],
  '0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925': [Function: bound ],
  'Approval(address,address,uint256)': [Function: bound ],

  LogNote: [Function: bound ],
  '0xd3d8bec38a91a5f4411247483bc030a174e77cda9c0351924c759f41453aa5e8': [Function: bound ],
  'LogNote(bytes4,address,bytes32,bytes32,bytes)': [Function: bound ],

  Transfer: [Function: bound ],
  '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef': [Function: bound ],
  'Transfer(address,address,uint256)': [Function: bound ],

  allEvents: [Function: bound ]
}

However, I was not able to check this properly, e.g:
1. event.watch does not work for me because of web3 v1
2. I tried using WebsocketProvider
web3.eth.subscribe("logs", { address: "0x23..." },
    function(error, result) {
        console.log("subscribe result:",result);
        console.log("subscribe error:",error);
    })
    .on("connected", function(subscriptionId) {
        console.log("subscriptionId:" + subscriptionId);
    })
    .on("data", function(log) {
        console.log("data:" + log);
    })
    .on("changed", function(log) {
        console.log("changed:" + log);
    });

However, I was not able to see smth when I trigger event
await contractIntanse.methods.rely(address1);

Here is related issue I managed to find
https://github.com/ethereum/web3.js/issues/1752
3. I also tried to use getPastEvents, as latest issues/1752 suggested
const eventOptions = { filter: {}, fromBlock: 0, toBlock: 'latest' };
const events = await contractIntanse.getPastEvents('LogNote', eventOptions);

It works ok for standartd event. However, for LogNote I get an error:
Error: overflow (operation="setValue", fault="overflow", details="Number can only safely store up to 53 bits")

Eventually, I'm very confused, do we able to listen MakerDAO's LogNote?
Appreciate any help, link to docs, discussions etc. Thanks!
ADDITIONAL:
I'm using DAI contract
https://etherscan.io/address/0x6b175474e89094c44da98b954eedeac495271d0f#contracts
Here is a commit was used for deployments on mainnet. I used as a base.
https://github.com/makerdao/dss/blob/6fa55812a5fcfcfa325ad4d9a4d0ca4033c38cab/src/dai.sol
The LogNote takes from LibNote. It what I'm trying to listen.
https://github.com/makerdao/dss/blob/6fa55812a5fcfcfa325ad4d9a4d0ca4033c38cab/src/lib.sol


texts: Airdrop generated token to multi address by contract failed

texts:
Below is my operation steps：

I create a token  0x260c4b1cd063599949b530454d22081b94c170ef whose owner is 0xAbA5862c54254750b2EFe8BEB72f528DAF73547F
You can check this token's code by https://etherscan.io/address/0x260c4b1cd063599949b530454d22081b94c170ef#code
compile version is : 0.4.22+commit.4cb486ee.Emscripten.clang
then publish a contract using @Rajesh code Unable to check Airdropped Tokens , the contract address is https://etherscan.io/address/0x7449605903e5e851f34d78accbe78e4c54dbab45 whose owner is also 0xAbA5862c54254750b2EFe8BEB72f528DAF73547F same as above token, compile version is also 0.4.22+commit.4cb486ee.Emscripten.clang
I sent some token to above contract from owner , tx is https://etherscan.io/tx/0x6e8091e585b63c62103ebb1fbc40d90c5604f5b6459b7ddd4eecf6794a183b7b
with parity I call transfer by below bash command

  owner=0xAbA5862c54254750b2EFe8BEB72f528DAF73547F
  to=0x7449605903e5e851f34d78accbe78e4c54dbab45 methodid=0xad8733ca
  array_0=0000000000000000000000008138ee2d269b1d85a81df6dd925f1f83d1ffa7cf
  array_1=0000000000000000000000000000000000000000000000000000000000000001
  data=${methodid}${array_0}${array_1}
  curl  -X POST -H 'content-type:
  application/json' --data '{ "jsonrpc": "2.0","method":
  "personal_sendTransaction","params": [{"from":
  "'"$owner"'","to":"'"$to"'","data": "'"$data"'"},"'"$PASS"'"],"id":
  1}' http://127.0.0.1:$port

transaction done well, but no any token is transfered , transactions is https://etherscan.io/tx/0x0dbc844714ae2d3b3310ee9b7efac6f930160e55559b1b634a59bdc4f33bef1d

Please help me to check , thank you very much


texts: Else if structure gives the wrong output

texts:
I have a little problem with a else if struture that doesn't give out the right result.
Here is the code:
pragma solidity  >=0.5.16;

contract SupChain{

    enum StateType {A, B, C}

    function elseIf(string memory houseA, string memory houseB,
                    int a, int b, int c) public view returns(StateType){
         StateType orderState;
        if(keccak256(abi.encodePacked(houseA))==keccak256(abi.encodePacked(houseB))){
            orderState = StateType.C;
        }else if(a < b || a > c){
            orderState = StateType.B;
        }else if(orderState != StateType.B){
            orderState = StateType.A;
        }
        return orderState;
    }
}

Let's says I use the following values:
houseA = 'Little';
houseB = 'Little';
a= 10;
b = -5;
c = 5;
Normally the function should return me the state B (the number 1) as an output since here a>c. However, when tested I get the state C (the number 2) as an output.

I thank in advance anybody who will help me.


texts: How to call get method of one contract from another?

texts:
I want to call a method of a contract from another contract. I've already read this post:
calling one contract to another contract method, but it doesn't work for me.

When I create the caller and try to execute the Set() method it perfectly works, but if call the Get() it alwayas returns '0'.

Can someone help me?

These are my simple code:

pragma solidity ^0.4.0;

contract callee{

    uint public x;

    constructor() public
    {
        x = 1;
    }

    function set (uint k) public
    {
        x = k;
    }

    function get () public view returns (uint)
    {
        return x;
    }

}

contract caller{

    callee c;

    constructor() public
    {
        c = new callee();
    }

    function get() public view returns (uint k)
    {
        return c.get();
    }

    function set(uint k) public
    {
        c.set(k);
    }

    function get_calle() public view returns (callee)
    {
        return c;
    }

}

I'm using Web3 Provider and Remix to test.

I have tried to call get() from the callee after getting its location, and it returns the right value, so the set() methods works. Why can't I use get() from the caller?

Thank you!


texts: Web3.py with Ganache - Error "from not found", 'code': -32000

texts:
I have opened an instance of ganache at localhost port 9545 where I can connect with web3.py.
However when I am trying to perform a transact using the below code:
w3 = Web3(Web3.HTTPProvider('http://127.0.0.1:9545'))
ExampleContract = w3.eth.contract(abi=abi, bytecode=bytecode)
tx_hash = ExampleContract.constructor().transact()
I am getting the following error:
ValueError: {'message': 'from not found; is required', 'code': -32000, 'data'
This is straight from the documentation here
Any ideas?


texts:
I have a token contract and I want to add liquidity to Uniswap (mytoken + ETH).
Before that, I would like to know the pair address in order to set it in my contract.
Is it possible to create a pair on the Uniswap Factory contract before adding liquidity to the pair?
I have seen that the Factory contract has that write function. Should I just add my token address and WETH one?
I would like an answer from someone who has used it in a similar a way, since once I setup the pair address in my contract it cannot be changed anymore.


texts: Getting continuous warning in logs of my geth instance


texts: What geth command options have been depreciated/removed?

texts:
I'm looking at this tutorial.

It includes this line:

geth --genesis %PATH%/Ethereum/testnet/genesisblock.json --datadir %SAME_PATH%/Ethereum/stateinfo --networkid 1234 --nodiscover console

As I understand it, the genesis command option has been depreciated.

My attempt at re-interpretation, using init is:

geth  --datadir "%SAME_PATH%/Ethereum/stateinfo" --networkid 1234 --nodiscover init "%PATH%/Ethereum/testnet/genesisblock.json" console

However this fails with

I0214 19:15:23.475842 node/config.go:445] Failed to start Ledger hub, disabling:
 libusb: not found [code -5]

What is the correct re-interpretation of the above line?

Is there a set of before and after use-cases for depreciated commands?

EDIT - full console coutput:

geth  --datadir "c:/mypath/testnet/" --networkid 1234 --nodiscover init "c:/mypath/testnet/genesis.json" console
I0214 19:15:23.475842 node/config.go:445] Failed to start Ledger hub, disabling:
 libusb: not found [code -5]
I0214 19:15:23.476842 cmd/utils/flags.go:613] WARNING: No etherbase set and no a
ccounts found as default
I0214 19:15:23.477842 ethdb/database.go:83] Allotted 128MB cache and 1024 file h
andles to c:\mypath\testnet\geth\chaindata
I0214 19:15:23.529845 ethdb/database.go:176] closed db:c:\mypath\testnet\geth\chain
data
I0214 19:15:23.530845 ethdb/database.go:83] Allotted 128MB cache and 1024 file h
andles to c:\mypath\testnet\geth\chaindata
I0214 19:15:23.566847 cmd/geth/chaincmd.go:132] successfully wrote genesis block
 and/or chain rule set: ba4fe4055a968c1b05a1254289164e7665cfef89782dcc7dcaec2e5e
4edc83a6

It then exits - which I wasn't expecting. I was expecting a console or an ipc instance to attach geth to...


texts: Analogue web3.eth.accounts.sign (from web3js) in web3py

texts:
There is a function web3.eth.accounts.sign in the implementation of web3js. But I cannot find the exact equivalent in web3py I don't see this. I found something similar to this — the signHash function (link https://web3py.readthedocs.io/en/stable/web3.eth.account.html#sign-a-message). This documentation says that the same hashing mechanism, but as a result, execution returns not the same as in web3js (web3.eth.accounts.sign).

I used this function in web3js to get signature (and then using ECDSA library (on Solidity) to get signer. On web3js works correctly (but on web3py - no). I connect to test network (ropsten) via Infura.

On web3js (where msg - what is signed):

let signature = await web3.eth.accounts.sign(msgHash, '0x' + privateKeyUser);
console.log('signature ='+signature.signature);

On web3py (I try, but doesn't work):

signature = web3.eth.account.signHash(msgHash, '0x' + privateKeyUser)
print('signature ='+signature.signature.hex())

And for example in variable "msgHash" value: 0x058c3b4c8e5dc4632b5c6b861b2c1861d53e426dc673c907ddf2651942b0f230
And at the output of web3js function (web3.eth.accounts.sign), we get signature:
0xd19241ed816026e846c8511e03a468aa6e038165ecb3c2229eee38b04c64b235408389dfad2b65d776dba236e7de1b63fdb6b2579e70c4ce9ad1b09a35da96521c
And this is the correct value. Web3py has other value.

What is exact analogue in web3py of how this web3.eth.accounts.sign function works in web3js?
Thank you!


texts: Ethereum Wallet downloading blocks - How to handle that memory size?

texts:
I'm syncing the Ethereum node for a while now. It almost finished, but I gradually need to delete files, because it'd barely fits my disk. I only have an iMac with a 256 GB SSD and ethereum takes like 75% or so of it :/
Is this normal? Do other people struggle with this or is it just me having a small hard disk? I also have a SD card with 64 GB free, could I transfer it there? I'm also concerned not to lose my 10 ETH.

Thank you in advance!


texts: Contract deployment throws block gas limit error

texts:
I'm trying to deploy a smart contract in a test network, using a [meteor DApp][1]. I have this parameters for the genesis block:

gasLimit: "0x1388"

However, any time I try to deploy any single contract I get the following error:

Error: Exceeds block gas limit

Any idea of what I can do here?


texts: Make character count, count emoji's as 2

texts:
I have the following function:

function getCharacterCount(string str) constant
returns (uint length)
{
    uint i=0;
    bytes memory string_rep = bytes(str);

    while (i<string_rep.length)
    {
        if (string_rep[i]>>7==0)
            i+=1;
        else if (string_rep[i]>>5==0x6)
            i+=2;
        else if (string_rep[i]>>4==0xE)
            i+=3;
        else if (string_rep[i]>>3==0x1E)
            i+=4;
        else
            //For safety
            i+=1;

        length++;
    }
}

Right now it totally works for all utf-8 strings so getCharacterCount(test1234) returns 8 but getCharacterCount(test1234)returns 9 where I want it to return 10. I could not find any working solution for this issue.


texts: Is there a list of safe low-bandwidth software wallets?

texts: Suppose a user has very limited access to the Internet and needs a safe low-bandwidth wallet while awaiting a hardware wallet.


texts: Can queue of pending transactions will be confirmed if send last transaction with high gas price?

texts: I have several pending transactions from the same account with a low gas price. What if I send one more transaction with next nonce but high gas price? Can it help to mine all pending transactions queue behind last "expensive" transaction?


texts: MetaMask won't send txs on local dev chain

texts:
I'm running a local dev chain for development using Etherlime. When trying to interact with the chain using MetaMask, I get the following error:
MetaMask - RPC Error: Error: [ethjs-rpc] rpc error with payload {"id":2084025564758,"jsonrpc":"2.0","params":["0xf88902847735940082b6ae94254d97074fb0053437dffadd6bac5c3af19781a580a47048027500000000000000000000000056a32fff5e5a8b40d6a21538579fb8922df5258c820a95a0afdd402623efd96be41e863da2c38130f9d2092ea66b8a8aa2dd4ecf7864da3da024b3f0aad9be55b31b6dc035f0c3a9f22a8b2f7e2331668214abe9b1cde6239f"],"method":"eth_sendRawTransaction"} [object Object]
Object { code: -32603, message: "Error: [ethjs-rpc] rpc error with payload {\"id\":2084025564758,\"jsonrpc\":\"2.0\",\"params\":[\"0xf88902847735940082b6ae94254d97074fb0053437dffadd6bac5c3af19781a580a47048027500000000000000000000000056a32fff5e5a8b40d6a21538579fb8922df5258c820a95a0afdd402623efd96be41e863da2c38130f9d2092ea66b8a8aa2dd4ecf7864da3da024b3f0aad9be55b31b6dc035f0c3a9f22a8b2f7e2331668214abe9b1cde6239f\"],\"method\":\"eth_sendRawTransaction\"} [object Object]", stack: "Error: Error: [ethjs-rpc] rpc error with payload {\"id\":2084025564758,\"jsonrpc\":\"2.0\",\"params\":[\"0xf88902847735940082b6ae94254d97074fb0053437dffadd6bac5c3af19781a580a47048027500000000000000000000000056a32fff5e5a8b40d6a21538579fb8922df5258c820a95a0afdd402623efd96be41e863da2c38130f9d2092ea66b8a8aa2dd4ecf7864da3da024b3f0aad9be55b31b6dc035f0c3a9f22a8b2f7e2331668214abe9b1cde6239f\"],\"method\":\"eth_sendRawTransaction\"} [object Object]" }

I see a similar issue here, there putting eip155:0 in the genesis.conf was supposed to solve the problem, but there doesn't seem to be any genesis file in dev chains, at least as far as I can tell. (I did a git grep on my project, and also searched Etherlime's GitHub repo.) If that's the case, this would need a different solution.
Any ideas?


texts: Why is my @uniswap/sdk DAI/USDT price impact at 100 and returning incorrect prices?

texts:
Following the documentation here: https://uniswap.org/docs/v2/javascript-SDK/pricing/
I have been able to replicate the results using WETH, and I have decided to have a go at getting a similar result with DAI and USDT.
const { ChainId, Fetcher, Route, Trade, TokenAmount, TradeType, WETH } = require('@uniswap/sdk');

const init = async () => {
    const dai = await Fetcher.fetchTokenData(ChainId.MAINNET, '0x6B175474E89094C44Da98b954EedeAC495271d0F');
    const tether = await Fetcher.fetchTokenData(ChainId.MAINNET, '0xdAC17F958D2ee523a2206206994597C13D831ec7');

    const pair = await Fetcher.fetchPairData(dai, tether);
    const route = new Route([pair], tether);

    const trade = new Trade(route, new TokenAmount(tether, '1000000000000000000'), TradeType.EXACT_INPUT);
};

init();

I retrieve the Token Data for both Dai and Tether, then fetch pair data which I then put into a route.
These abovementioned steps must be correct as the an in-function log of
console.log(route.midPrice.toSignificant(6));
console.log(route.midPrice.invert().toSignificant(6));

return values that make sense.
Where things become odd is with
console.log(trade.priceImpact.toSignificant(6));
console.log(trade.executionPrice.toSignificant(6));
console.log(trade.outputAmount.toSignificant(6));

According to these results, my price impact is at 100, the execution price is around 0.000000278029, and the output amount is at 278028.
This doesn't sound right at all.
What is the mistake in my code that brings about this error?


texts:
I am trying to install oraclize with truffle.

When i run 'truffle install oraclize', I get an error:

Could not find suitable configuration file.

I am using truffle v4.1.7

Thanks in advance..


texts:
I understand ERC20 is a specification. I found some implementations like the following:

https://theethereum.wiki/w/index.php/ERC20_Token_Standard
https://github.com/ConsenSys/Tokens

I want to create my own token. What is the most used ERC20 implementation? I'd like to use that.

Update

Thanks to Abhishek's suggestion, I found an OpenZeppelin tutorial which integrates with truffle. Quite easy to understand!

Robust Smart Contracts with OpenZeppelin


texts: Is it possible to embedd the UI of DApp in the blockchain?

texts:
I have read the answers for this question as well as their linked resources, but I didn't found the answer for the following question:

is it possible to embedd the UI of ÐApp in the blockchain?

If I provide the UI (HTML, js) for the distributed app, then I retain some kind of possibility to change the way my application is working, according to my current needs. I can hide or process some information, I can store the user input in my database etc. But I would like to ensure the end users of my app that I'm not able to intercept or change theirs data.


texts:
I have a contract with a function that takes as parameter a bytes32, and a mapping that uses a bytes32 as key.

In geth, it seems like I can call contract.foo("0x123abc") and contract.foo(0x123abc), but I'm not sure they give the same results.

Same for contract.mymap("0x123abc") and contract.mymap(0x123abc), are they the same ? Are they always processed as 0x123abc0000000000000000000000000000000000000000000000000000000000 ? Bytes are similar to strings but I'm not sure of the difference.

I can't test anything I want on my contract, but I checked and both map(0x1234567890abcdef123) and map("0x1234567890abcdef123") work but give different results. Which one should I use ?


texts: Understand an online contract with no EVM bytecode avaliable

texts:
Could anyone shed some lights on the following contract?

https://etherscan.io/address/0x27d6c4cb2551799a143e1a3291ae002b8c8aa078#code

I am quite confused about what's going on here. Why doesn't the "EVM bytecode" of the contract show up on etherscan.io? Or it is because it has been self destructed or something?

Any suggestion would be appreciated very much.


texts: Give Web3 a description of smartcontract function

texts:
Today i tested something on Uniswap when I came across a feature of Metamask or Web3 where a specific function call can have a custom Description.

As seen in the Picture, Metamask somehow got a String which replaced the normal "Contract interaction" Title. Since this is definitely not the Name of the function, and I didn´t find anything in the documentations of both web3 and Metamask, I wonder how this works.
How can I set this custom description when calling a contract with web3?


texts: Nodes from two different networks not operable on a private blockchain

texts:
This is how my setting looks:

H2 and H4 are on separate networks. They have private IPs and not routable from outside the network. How do I make these two systems as peers so that they operate on the same private blockchain network? I tried using Public IP in the enode URI with the addPeer() function but the connection was not successful.

Edit:

As @Badr suggested, --nat with extip worked, but this cannot be used for connecting two systems with the same public IP i.e., the public IP cannot be translated to two private IPs. I tried using a different port # but the connection wasn't successful. Is there any solution for this?


texts: Do nodes by default relay transactions that fail and spend all gas (e.g. Solidity throw)?

texts: How do nodes (not necessarily miners) treat transactions that result in Solidity throw (i.e. Out Of Gas error, transaction reverted)? Such transactions' only effect is gas (ether) transfer from the sender's account to the miner. So miners have incentive to mine them; but do nodes relay them by default?


texts: Can someone share your geth export file with me?

texts:
I need to setup an archival node ASAP but the download takes around 1-2 block per second. With this speed it will finish in 2 months (if it doesn't stall, but it does, I have to restart it manually every time).

Can some of you share your (geth) export file for the Main net ?

Thank you in advance


texts: How to import a plain private key into Parity?

texts:
Basically the parity version of this.

Can Parity import raw private keys or Geth keystore files?


texts: How to make transaction of some ether in Buyer Seller type of contract?

texts:
In this I have set modifier (msg.sender == sellerAddress) which is not valid.
But in this scenario, I want to allow only and only sellerAddress to take ether from my contract. How can I allow only seller address to do this. As well as which kind of inputs I have to enter while executing contract?

contract ContractDemo {
    address public buyerAddress;
    address public sellerAddress;
    uint public price; //price or charge for delivering parcel

    modifier onlyBuyer() {
        require(msg.sender == buyerAddress);
        _;
    }

    modifier onlySeller() {
        require(msg.sender == sellerAddress);
        _;
    }

    constructor(address payable _sellerAddress) public payable {
        buyerAddress = msg.sender;
        sellerAddress = _sellerAddress;
        price = msg.value;
    }

    function deliveredParcel(address payable _seller) onlySeller public payable returns(bool) {
        require(msg.value == price);
        _seller.transfer(msg.value);
        return true;
    }
}


texts:
I am going through the solidity docs and I have seen that:
    // Functions can
    // be accessed directly or through `this.f`,
    // but the latter provides an external view
    // to the function. Especially in the constructor,
    // you should not access functions externally,
    // because the function does not exist yet.

At what circumstances should you use this in a constructor?


texts: What is impacting generated contract address?

texts:
What is used to generate contract address.
I found this project https://github.com/johguse/profanity
And I want to generate vanity contract address.
If I understand correctly it not depends from contract code, but only nonce.
  Advanced modes:
    --contract              Instead of account address, score the contract
                            address created by the account's zeroth transaction.

Am I correct?


texts: Creating a two-dimensional tier structure in Solidity

texts:
Consider the case wherein there needs to be a price tier structure that needs to be deployed on the network. Take the following tier structure for example:
Tier|Region 1|Region 2|Region 3
1|11.99|0|0
2|12.99|0|0

 uint[3][2] tier;
 tier = [[1199,0,0],[1299,0,0]];

Essentially what needs to be established is, if a certain price of a product is below 11.99, then the value needs to be taken as 11.99 and similarly for the second tier. I have tried leveraging multi-dimensional arrays but have been facing errors in conversion.

Any suggestions as to how I can resolve this issue and retrieve the values by querying the array?


texts: web3 sendTransaction returns tx but getTransaction retuns undefined when Geth is restarted

texts:
js code:

const Web3 = require('web3');
const web3 = new Web3();
const {eth, personal} = web3;

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

personal.unlockAccount(eth.coinbase, '12345678');

const tx = eth.sendTransaction({
  from: eth.coinbase,
  data: web3.toHex('Hello World'),
});

console.log(eth.getTransaction(tx));

And run it with from bash:

local SCRIPT=${1:-web3.js}
geth --dev --mine --rpc --rpcaddr "0.0.0.0" --rpcapi "admin,debug,miner,shh,txpool,personal,eth,net,web3" &
local PID=$!

sleep 3

node "$SCRIPT"

sleep 1
kill -s 9 $PID

Nodejs script output is:

{ blockHash: '0x0000000000000000000000000000000000000000000000000000000000000000',
  blockNumber: null,
  from: '0xdfb1b9b8693366eb9044ffd8c00058abc904558b',
  gas: 90000,
  gasPrice: { [String: '20000000000'] s: 1, e: 10, c: [ 20000000000 ] },
  hash: '0x0b4f742149fc3018a168950b56786846da99675913dbc043971cbe25ac7792ac',
  input: '0x48656c6c6f20576f726c64',
  nonce: 2,
  to: null,
  transactionIndex: null,
  value: { [String: '0'] s: 1, e: 0, c: [ 0 ] } }

But sometimes there is no such transaction when I restart geth. How long transactions need to be put into the block and how to check it's added/rejected?


texts: I to want introduce myself to learn new and advanced technologies like AI, blockchain

texts:
I have completed 2days blockchain executive program two weeks back. Course covers high-level concept on blockchain, ethereum

I have around 12+ yrs of IT experience and worked on different tools and technologies.

I want to introduce myself to learn new and advanced technologies like AI, blockchain. Please suggest how to start.

Regards
Amaresha Gante
+919740010891
coolamx@gmail.com


texts: If you have to stake your coins in PoS how can you make sure not to validate a fraudulent transaction

texts:
I have a number of questions involved here.

What is a fraudulent transaction? Is there an example of this on the blockchain?
Just to verify, in PoW the hashing algorithm is calculated to pass from one node to another and therefore there's no way that the transaction is fraudulent because otherwise the computation could not be completed, correct?
How is staking coins doing the same verification process? What is the computation that occurs that verifies the tx? Also, how could a staked node verify a fraudlulent tx and then do the really lose their coins?

Sorry for all the questions combined, but they all lead me to better understand the first question I posed in title.


texts: How can I access a contract's fallback function via 'myContract.methods'?

texts:
Web3.js documentation says here that the methods of a smart contract are available through:

The name: myContract.methods.myMethod
The name with parameters: myContract.methods['myMethod(uint256)']
The signature: myContract.methods['0x58cf5f10']

But how can I access the contract's fallback function, which has no name (and no parameters)?

Will the 2nd option work if I use myContract.methods['()']?

Is there a way to make the 1st option work?

Thank you!


texts: Why is my TX failing due to lack of gas even though the correct amount of gas was supplied?

texts:
Caveat: I tried to provide links to my transactions and addresses in etherscan.io, but I "need at least 10 reputation to post more than 2 links."

I have an account that I want to sweep. I want to sweep the ETH to a funds splitting contract (ETC/ETH). I'm only interested in sweeping the ETH balance and my goal is for the account to end up with a balance of zero (e.g. no dust).

This is the fund splitting contract I'm trying to use: 0x1e143b2588705dfea63a17f2032ca123df995ce0

It seems as if the gas required for this operation is 29,717. For example, here is a sample transaction I sent to the contract, which according to etherscan.io required that amount of gas: 0x7cd52325c0945d0de975a6713abdc50659c0c62ef523a1a99f2ad2a2d4128a8f

However, if I send a transaction and limit the amount of gas to 29,717, my transaction fails. For example, here is a sample transaction I sent to the contract with a gas limit of 29,717, which failed due to lack of gas: 0xcd31481b4dd9410daa22c8a47f9a4b29ef4a305877174eb346433bb4e6b03089 (TX)

I discovered the minimum amount of gas that I need to specify for one of these transfers to work is 31,991:

Transaction with 31,991 gas which worked: 0x7cd52325c0945d0de975a6713abdc50659c0c62ef523a1a99f2ad2a2d4128a8f (TX)
Transaction with 31,990 gas which failed: 0x8c92fde3cf07b3cdbf4dcc54ed6ccfb072f22933ab556612f3d23317a2466280 (TX)

However, when the tx goes through, it seems as if it only used 29,717 gas. For example:
Account 0x19d90f1106c600bd8a70b5775776b4ecdc7a945b (address) had a balance of 0.01282711 ETH (at block 1964300).

I sent transaction 0xb57c8b5aede3070e2fb80ea9a21ec43293cb5c7392ccb36357388422e9055509 (TX) with the following details:

Value: 0.01218729 ETH
Gas: 31991
Gas Price: 20000000000 Wei

So:

Balance before TX: 0.01282711 ETH
Amount to send: 0.01218729 ETH
Supposed cost of TX: Gas * Price = 0.00063982 ETH
Balance - Amount to send - Supposed cost of TX = ZERO!

However, as you can see, account 0x19d90f1106c600bd8a70b5775776b4ecdc7a945b (address) has a balance of 0.00004548 ETH.

This in turn means that the actual cost of the TX was 0.00059434 ETH: Actual Cost of TX = Balance before TX - Amount sent - Actual End Balance = 0.01282711 - 0.01218729 - 0.00004548 = 0.00059434.

At a gas price of 20000000000 Wei, this means the amount of gas used was: 29717 (0.00059434/0.00000002 = 29717)

So the question are:

Why are the transactions which specify a gas limit of 29717 failing?
How do I sweep the funds so the ending balance of an ETH account is zero when using the contract above?

System information

Geth version: 1.4.10-stable-c2eea630
OS & Version: Linux

Expected behaviour

Transaction 0x19d90f1106c600bd8a70b5775776b4ecdc7a945b should've been successful.

Actual behaviour

Transaction 0x19d90f1106c600bd8a70b5775776b4ecdc7a945b failed due to lack of gas.

Steps to reproduce the behaviour

Use the transfer(address) function of contract 0x1e143b2588705dfea63a17f2032ca123df995ce0 by sending some amount and limit the amount of gas to 29717

Here is a sample transaction to this contract you can send via the JSON-RPC API:
'{"jsonrpc":"2.0","method":"eth_sendTransaction","params":[{"from":"0xe7c7d161800ebb5112d7d892510e9f1dafc4010c","to":"0x1e143b2588705dfea63a17f2032ca123df995ce0","value":"0x1F99A58657EED0","data":"0x1a69523000000000000000000000000029d5527caa78f1946a409fa6acaf14a0a4a0274b"}],"id":6}'


texts: Gas cost of adding an item to a class-level (storage) array

texts:
I would like to make sure that the gas cost of adding an item to a (storage) array is constant, i.e., not dependent on the length of the array.

To my understanding, the relevant EVM operation is SSTORE, which according to this spreadsheet (taken from the yellow paper), has indeed a "more or less constant" gas cost.

In addition to that, I also found this answer to support it, stating:

  As far as I know, adding an item to an array/mapping will cost the same gas regardless of how many items that array/mapping already is storing.

Due to the "as far as I know" part, I also executed some testing against a "real" EVM (using Truffle and Ganache).

Here is my on-chain code:

pragma solidity ^0.4.24;

contract MyContract {
    uint256[] public array;
    function justPush(uint256 value) external {
        array.push(value);
    }
}

Here is my off-chain code:

contract("test", function() {
    it("pushing an 'all-0s' value", async function() {await justPush(1);});
    it("pushing an 'all-1s' value", async function() {await justPush(2);});

    async function justPush(n) {
        let myContract = await artifacts.require("MyContract.sol").new();
        let value = web3.toBigNumber(n).pow(256).minus(1);
        for (let i = 0; i < 1000; i++) {
            let gas = await myContract.justPush.estimateGas(value);
            await myContract.justPush(value);
            console.log(gas);
        }
    }
});

And here is my observation:

Pushing an "all-0s" value costs 46951 units for the first insertion and 31951 units for every other insertion
Pushing an "all-1s" value costs 63999 units for the first insertion and 48999 units for every other insertion

As I started off with - I would like to make sure that the gas cost of this operation is indeed constant, even though the operation of adding an element to an array which not implemented as a linked list has a theoretical time complexity of O(n).

Also, am I right in guessing that the difference between the first insertion and every other insertion is due to the fact that the length of the array is changed from 0 to 1?

Thank you!


texts: What is the difference between the transfer and transferFrom function in an ERC721 contract

texts:
Using web.js, I am trying to transfer erc721 tokens across different addresses.
In case of cryptokitties, I can do the transfer using transfer function only while in case of cryptoheroes, I can use the same contract but do the transfer only using transferFrom.

What exactly is the difference between the two?
How can I write a generic code which will work when I want to transfer the tokens for all ERC721 contract? Or do I need to have the contract ABI for each contract?


texts:
I am receiving the error: "Unhandled Rejection (TypeError): this.provider[(intermediate value)(intermediate value)(intermediate value)] is not a function".

However, I have not used "this.provider" in my code. My code is provided below. Does anyone know how I could resolve this?

Help would be insanely appreciated!


texts: Send more than one raw transaction quickly will throw an error

texts:
web3.eth.getTransactionCount(addressFrom).then(function(v){
    count = v;
    var amount = web3.utils.toHex(1e16);
    var rawTransaction = {"from":addressFrom, "gasPrice":web3.utils.toHex(20* 1e9),"gasLimit":web3.utils.toHex(210000),"to":contractAddress,"value":"0x0","data":contract.methods.transfer(addressTo, amount).encodeABI(),"nonce":web3.utils.toHex(count)}
    var transaction = new Tx(rawTransaction);
    transaction.sign(privKey);
    web3.eth.sendSignedTransaction('0x'+transaction.serialize().toString('hex'))
    .on('transactionHash',console.log);
});

If I send more than one raw transaction quickly, I get the known transaction error. I got

  "UnhandledPromiseRejectionWarning: Error: Returned error: known transaction: 288cd7f1dc2dXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX".

Maybe something is without the 0x, but I don't know how to do that.


texts: Please provide a summary of the Ethereum hard forks

texts: The question Please confirm what the hard forks of Ethereum were and when they took place was asked on Reddit by u/Tykerr.


texts: Geth additional condition for valid blocks in private network

texts: Using Geth and a private blockchain, is there any possibility to specify an additional condition for a block to be valid? In particular, I want to accept only blocks that are mined from miners that are listed in a smart contract. Other blocks should just be ignored. The purpose is to secure a private testnet where the vaild miners change over time (by vote). I think it would also be a good idea, if no miner could mine two consecutive blocks. Is this possible?


texts:
This is a weird question but it's hard to search for because I get mathematical uses of the term "limit" and and other uses of 9.2, etc.  So.

Question: is 9.223372 ETH a significant number?  Because no matter how many ETH I send (on mainnet) the limit seems to be 9.223372.

The account has MUCH more than 9.23ETH.  Also, it sends the 9.223372 each time.  So I can make multiple transactions but each one sends only 9.223372ETH.

I am using Parity latest and the blockchain is fully synced.  I am on mainnet.

Please do not overthink.  Either this number is going to be obvious, or the idea of a limit is going to be obvious.

If I don't get an obvious answer, then I need to start looking at logs.  And then I will come back with a specific question.  But I thought maybe "everyone knows" that 9.22 is a magic number so I wanted to ask first.


texts: Questions about upgrading an old PC for Ethereum mining

texts:
I am upgrading an old PC because I would like to start mining with it.

Could the old mainboard Gigabyte MA770t-UD3 utilize the full potential of a high-end graphic card for mining purposes? At least something as good as Radeon 6800 XT?

Is 4 GB DDR3 RAM good enough?

What do you suggest as the minimum for a power supply?

Is there any way to put two graphic cards on this mainboard?

Thanks


texts: How to get multiple values from one function contract to another

texts:
I have two contract and in first contract it contains a function which is responsible for returning two values, one of string and one of integer.

function getUserData(address userAddress)
    public    constant    returns(string, uint)
  {
    string Firstname = "Hello";
    uint number=123;
   return( Firstname,number);
  }

On compiling this gives error
"Type literal_string "Hello" is not implicitly convertible to expected type string storage pointer.
    string Firstname = "Hello";
"
In the second contract I make object of first contract and tried to get function

function FetchDetail(address userAddress) public constant returns(string,uint )
  {
    string memory  data1;
    uint  data2;
    UserRegistration ud=new UserRegistration();
   (data1,data2)= ud.getUserData(userAddress);
    return(data1,data2);
  }

But I am unable to get values. Please suggest me.


texts:
I added the below three functions to my deployed contract as described in the article https://programtheblockchain.com/posts/2017/12/15/writing-a-contract-that-handles-ether/
I deployed using Remix on Rinkeby.  When I enter 1 Ether into the Deposit transaction in Remix I get the "Gas Estimation Failed" Error.
Why is the Deposit function generating an error?
Thank you
function withdraw() public {
msg.sender.transfer(address(this).balance);
}
function deposit(uint256 amount) payable public {
    require(msg.value == amount);
    // nothing else to do!
}

function getBalance() public view returns (uint256) {
    return address(this).balance;
}

Update
I tried to use a fallback function but Remix is not liking it.
pragma solidity >=0.4.0 <0.7.0;
Thank you


texts: Where is the contract deployed when created with factory contract

texts:
I am new to ethereum.

I am trying to create a contract from a factory contract, which works fine and even returns the address of the newly created contract

Contract FactoryContract {
    event ContarctCreated(address index contractAddress)
    address[] public alladdresses;
    function CreateChild(string memory arg1) {
        address newChild = ChildContract(_arg1)
        alladdresses.push(newChild)
        emit ContarctCreated(newChild)

    }
}

Contract ChildContract {
    string arg1;
    constructor(string memory _arg1) public {
        arg1=_arg1;
    }
}

Now I want to load this newly created child contract through UI (web3) in  my case.How would I do it?
If I try this in Remix and click ATADDRESS button, I get the relevant details of the contract.I want these details to be loaded through my UI.
Any help is really appreciated.


texts: We are running a dbix pool on open eth pool was workin fine until 3 days ago and now it's out of sync with the network . I re installed the pool but still have the issue not syncing but has correct block height. I'm confused any help would be great thanks in advance


texts: How do I compile using the nightly build of the Solidity compiler

texts:
Using the Remix IDE, I'd like to try out some of the new features of Solidity by using the nightly compiler build, but it's giving me a wrong compiler error.

When I try

pragma solidity 0.6.0;

//...

while using version 0.6.0-nightly.2019.3.11+commit.4704ef84.Emscripten.clang

I get the error: ParserError: Source file requires different compiler version (current compiler is 0.6.0-nightly.2019.3.11+commit.4704ef84.Emscripten.clang - note that nightly builds are considered to be strictly less than the released version

trying pragma solidity ^0.5.7; works but then I cant try the new features.


texts: Ropsten Blockchain Size on Disk December 2019?

texts:
Hello what is the size of the Ropsten Blockchain, on disk, using Parity with full trace on?

(Info required to provision a VPS).


texts:
How is it possible for a block to be mined with 0 txn?

https://etherscan.io/block/6739171

That's an easy way to get 3 ETH block rewards.


texts: On-chain text encryption using Whisper protocol

texts:
Could one send a 10-character encrypted message within an ERC-20 transaction using the whisper protocol ON-CHAIN?

Or could that only be achieved by running private nodes and setting up a p2p server? What other ways are there to send short encrypted messages with a token transaction?


texts:
I have seen almost all the DApps have some kind of tokens, ICO associated with it.

Anyone kind enough to explain what is the relationship between a DApp and Tokens?


texts: All truffle commands left segmentation fault (core dumped)

texts:
This is the output of truffle compile:

> Compiling your contracts...
===========================
> Compiling ./contracts/Lent.sol
> Artifacts written to /home/supernozer/MyERC20/build/contracts
> Compiled successfully using:
   - solc: 0.6.7+commit.b8d736ae.Emscripten.clang

Segmentation fault (core dumped)

As well as truffle migrate --network ropsten --reset:

...
Summary
=======
> Total deployments:   2
> Final cost:          0.0753067 ETH

Segmentation fault (core dumped)

Any solution to fix this? Or just simply ignore since it doesn't interrupt anything?


texts: Transaction submitted through Infura, but not from local node

texts:
So, I have a Rinkeby fast sync on my server. When I try to interact with my contract and transfer something, geth says "Submitted transaction", but then I can't find it using its hash on etherscan. When I call the same contract function through Infura's Rinkeby node, with the same gas settings, etc., it does get propagated and I can see it on etherscan within a minute.

Anyone have any idea why that might happen? I noticed that when I list my peers, the network section looks like this:

network: {
  inbound: false,
  localAddress: "blabla:57204",
  remoteAddress: "blabla:30305",
  static: false,
  trusted: false
},

Should inbound be true in order for my node to submit transactions?

Thanks!


texts:
This is a fairly simple question which (I suspect) has a more complex answer. I would like to find out that answer now rather than the hard way down the line.

How many concurrent requests can an Ethereum node handle?

If I have a Parity/Geth node processing transactions to the chain, how much can I hammer it? web3.js communicates with a node utilising the JSON RPC protocol. I assume therefore that the bottleneck is thus the client serving those requests.. I.E the node.

So, does anyone have any insight? If I threw 1,000 pre-signed transactions at the node, what would happen? 10,000? 1 million?


texts:
I sent 0.1 ETH from Coinbase to Bittrex. The total transaction in Coinbase is 0.100441 ETH. I guess the difference is for the fees.

But the odd thing is I didn't receive 0.1 in Bittrex. I only got 0.09715353 ETH.

Here is the transaction: https://etherscan.io/tx/0x09c0097dc0abd1e6abb406572788502aba8a4769ead93c6d744626cf54763014

Can anybody explain to me what happened?


texts:
I tried running the commands from https://github.com/ethereum/go-ethereum/wiki/Private-network

CustomGenesis.json:

{
    "config": {
        "chainId": 15,
        "homesteadBlock": 0,
        "eip155Block": 0,
        "eip158Block": 0
    },
    "difficulty": "200000000",
    "gasLimit": "2100000",
     "alloc": {
     "0x9370855ace244dc18fba024988046dde0d9f8ad8": {
      "balance": "1000000000000000000000"
      }
    }
}

To create a database that uses this genesis block, run the following command. This will import and set the canonical genesis block for your chain.

geth --datadir path/to/custom/data/folder init genesis.json

Future runs of geth on this data directory will use the genesis block you have defined.

geth --datadir path/to/custom/data/folder --networkid 15

So I run the above with

geth --rpc --datadir path/to/custom/data/folder --networkid 15
WARN [03-05|19:33:23] No etherbase set and no accounts found as default
INFO [03-05|19:33:23] Starting peer-to-peer node               instance=Geth/v1.7.2-stable/darwin-amd64/go1.9.2
INFO [03-05|19:33:23] Allocated cache and file handles         database=/Users/quantum/cc/geth/path/to/custom/data/folder/geth/chaindata cache=128 handles=1024
INFO [03-05|19:33:23] Initialised chain configuration          config="{ChainID: 1 Homestead: 1150000 DAO: 1920000 DAOSupport: true EIP150: 2463000 EIP155: 2675000 EIP158: 2675000 Byzantium: 4370000 Engine: ethash}"
INFO [03-05|19:33:23] Disk storage enabled for ethash caches   dir=/Users/quantum/cc/geth/path/to/custom/data/folder/geth/ethash count=3
INFO [03-05|19:33:23] Disk storage enabled for ethash DAGs     dir=/Users/quantum/.ethash                                        count=2
INFO [03-05|19:33:23] Initialising Ethereum protocol           versions="[63 62]" network=15
INFO [03-05|19:33:23] Loaded most recent local header          number=0 hash=d4e567…cb8fa3 td=17179869184
INFO [03-05|19:33:23] Loaded most recent local full block      number=0 hash=d4e567…cb8fa3 td=17179869184
INFO [03-05|19:33:23] Loaded most recent local fast block      number=0 hash=d4e567…cb8fa3 td=17179869184
INFO [03-05|19:33:23] Loaded local transaction journal         transactions=0 dropped=0
INFO [03-05|19:33:23] Regenerated local transaction journal    transactions=0 accounts=0
INFO [03-05|19:33:23] Starting P2P networking
INFO [03-05|19:33:25] UDP listener up                          self=enode://cd3f867d2e6e268ab27e555e255097bb96f1f61381dcce74c90a11ee2f960e8542955764a14c7e96e5002b10eb2cc74badf29f974d4d3b61b936e2be36bfe7b6@[::]:30303
INFO [03-05|19:33:25] RLPx listener up                         self=enode://cd3f867d2e6e268ab27e555e255097bb96f1f61381dcce74c90a11ee2f960e8542955764a14c7e96e5002b10eb2cc74badf29f974d4d3b61b936e2be36bfe7b6@[::]:30303
INFO [03-05|19:33:25] IPC endpoint opened: /Users/quantum/cc/geth/path/to/custom/data/folder/geth.ipc
INFO [03-05|19:33:25] HTTP endpoint opened: http://127.0.0.1:8545

then in a new shell,

geth attach

geth attach
Fatal: Unable to attach to remote geth: dial unix /Users/quantum/Library/Ethereum/geth.ipc: connect: no such file or directory

so now I cannot connect to my test network.


texts: when do I know geth --fast is up to speed?

texts:
When do I quit geth --syncmode "fast" and run geth --syncmode "full" , how do I know it's done ?

currently running

web3.eth.getBlockNumber()
.then(console.log);

web3.eth.isSyncing()
.then(console.log);

logs:

{ currentBlock: 4402495,
  highestBlock: 4402734,
  knownStates: 14127294,
  pulledStates: 14114278,
  startingBlock: 0 }
0

am I done?


texts: what do I do with compiled interface output?

texts:
I created a token sale smart contract. And it has an interface that resolves to a token contract address.

Now the output folder has the compiled token sale smart json file and the interface json file.....

When I deploy the token sale smart contract, what do I do with the interface output?


texts: geth never completes syncing for rinkeby

texts:
My aim is to synchronise a full node for the Rinkeby network.
It seems that geth does not finish synchronisation. I have had it run for over three days, but it is stuck at the last few blocks.

> eth.syncing
{
  currentBlock: 4507244,
  highestBlock: 4507319,
  knownStates: 64751595,
  pulledStates: 64748954,
  startingBlock: 4507164
}
> eth.blockNumber
0
> admin.peers.length
1
> net.peerCount
1

When I rerun eth.syncing, then the highestBlock increases, but currentBlock doesn't.

I have tried installing different versions for geth (1.8.X, 1.9.0)
I also enabled network time synchronisation via
timedatectl set-ntp true
as suggested in this post: Geth is stuck syncing

I run geth via geth --rinkeby --cache 2048.

My machine has 12GB RAM and 8 CPUs.

Any help would greatly be appreciated. Thank you.


texts: In Mist browser how can I move the data (blockchain) to another drive on Mac OSX?

texts:
My Mac "System" drive is almost full. As I actually have two drives, I want to move the blockchain from the default location to the second drive.
How can I do it ?


texts: Ethers contract call reverted while passing on etherscan interface

texts:
I'm trying to implement 1inch exchange's getExpectedReturnWithGasMulti method in ethers.js. The contract is deployed at: https://etherscan.io/address/0x6e858ea1015e1c8da176f057d74dae0f35675aeb
When I try and call the getExpectedReturnWithGasMulti using the etherscan contract interface with the following parameters:
tokens: [0x6B175474E89094C44Da98b954EedeAC495271d0F,0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48,0x6B175474E89094C44Da98b954EedeAC495271d0F]

amount: 100000000000000

parts: [100,100]

flags: [0,0]

destTokenEthPriceTimesGasPrices: [10000000000,10000000000]

The contract returns a logical, valid response:

[ getExpectedReturnWithGasMulti method Response ]
returnAmounts   uint256[] :  1833,3544684228302442
estimateGasAmount   uint256 :  600000
distribution   uint256[] :  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,25700,0,0,0,0,0,0,0,0,0

Now when I try to call the method using ethers.js with the same parameters:
require("dotenv").config();
const { ethers } = require("ethers");
const BN = require("bn.js");

const oneInchAbi = require("./abis/1inch.json"); // copied from etherscan

const httpProvider = new ethers.providers.JsonRpcProvider("https://mainnet.infura.io/v3/" + process.env.INFURA_KEY);

let wallet = ethers.Wallet.fromMnemonic(process.env.MNEMONIC)
wallet = wallet.connect(httpProvider);

const onesplitContract = new ethers.Contract("0x6E858eA1015E1C8da176F057D74dae0f35675aEb", oneInchAbi, wallet.provider);

(async () => {
    const resMulti = await onesplitContract.functions.getExpectedReturnWithGasMulti(
        ["0x6B175474E89094C44Da98b954EedeAC495271d0F", "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", "0x6B175474E89094C44Da98b954EedeAC495271d0F"],
        "100000000000000",
        ["100", "100"],
        ["0","0"],
        ["10000000000","10000000000"]
    );

})()

The transaction is reverted

Error: call revert exception (method="getExpectedReturnWithGasMulti(address[],uint256,uint256[],uint256[],uint256[])", errorSignature=null, errorArgs=[null], reason=null, code=CALL_EXCEPTION, version=abi/5.0.2)


texts: How to expose Enum in Solidity contract?

texts:
If you create a contract with a function like:

contract MyContract {
  enum MyEnum { Foo, Bar }
  event ThingHappened(MyEnum indexed _e)
  function foo(MyEnum _e) {
    // Code, code code...
  }
}

Solidity compiles that enum variable type down an int8 (unless the enum has more than 8 options, in which case it walks up the int type scale), but that simply changes the signature of the foo function to be:

function foo(int8 _e)

and the event to be:

event ThingHappened(int8 indexed _e)

I'm not seeing a spelling out in the generated ABI JSON somewhere that spells out which int value goes with which enum value (e.g. 0 = Foo, 1 = Bar, etc.).

How best should contracts handle accepting an enum as an argument, or having an enum in an event, to share with the world what those integer values map to?


texts: Is it possible to extract private key from json/UTC file?

texts: I created an ethereum paper wallet on an offline computer. Do I need to keep both the private key and the UTC/json file or can I just keep the UTC/json file and extract the private key from it. Thank you.


texts:
Given the code below, geth returns:

{"jsonrpc":"2.0","id":"1","error":{"code":-32602,"message":
"json: cannot unmarshal object into Go value of type []interface {}"}}

The code connects to geth, but I am obviously sending the wrong data for params. Geth wants [] and not an object. If I change the code to send a string that looks like [], geth still complains.

Question: how do I send a [] to geth?

#[macro_use] extern crate hyper;
extern crate rustc_serialize;
extern crate url;

use std::io::Read;
use hyper::{Client};
use hyper::header::{Headers, ContentType};
use rustc_serialize::{Encodable, json};
use rustc_serialize::json::Object;

fn post_json<T>(url: &str, payload: &T) -> hyper::Result<String>
    where T: Encodable {
    let client = Client::new();
    let body = json::encode(payload).unwrap();
    let mut response = try!(client.post(url).header(ContentType::json()).body(&body[..]).send());
    let mut buf = String::new();
    try!(response.read_to_string(&mut buf));
    Ok(buf)
}
#[derive(RustcDecodable, RustcEncodable)]
struct Param {
    num: String,
    detail: bool,
}
#[derive(RustcDecodable, RustcEncodable)]
struct RpcRequest {
    jsonrpc: String,
    method: String,
    params: Param,
    id: String,
}
fn main() {
    let request = RpcRequest {
        jsonrpc: "2.0".to_owned(),
        method: "eth_getBlockByNumber".to_owned(),
        params: Param { num: "1".to_owned(), detail: true },
        id: "1".to_owned(),
    };
    println!("{}", post_json("http://localhost:8545", &request).unwrap());
}


texts: How to push reserved tokens to market after ICO

texts:
I have written a contract where 50% tokens are in reserve and owner wants to sale those tokens via Exchange. Should I add BUY function in contract to achieve this feature.

function buy() payable public {
    uint amount = msg.value/buyPrice;       /// calculates the amount
    _transfer(owner, msg.sender, amount);   /// makes the transfersowner account
}

If I add this function in contract, anybody can buy after ICO without involving exchange.

Need a guidance on this.


texts:
I've tried overnight mining and have had no luck. I first created an account using geth account new. Then I use geth --rpc to stay in sync with the blockchain and ethereum -G to start the minining process. I can see the program create the DAG and then proceed to mine at about 5MH/s.

The problem is that when I  use geth attach and check the amount I have mined it always returns zero (eth.getBalance (eth.coinbase) ). I mine for about 7 hours at a time and have no luck. Is this normal?

Also is it normal to not see your wallet/address when searching at etherchain.org?


texts: Something wrong with contract ABI and decoding input data using web3.py

texts:
I'm trying to decode some input data for this contract  0x24b22b031ae1b5a6b09f9a0fd33613a40e0d70e6, from this tx 0x30e2451138e443bcf69f59858df52eff647710dfa244d9b0e84c79504bb72fa5 (though the problem exists for any tx's I select for the given contract)
I'm running the following code to try and decode the input:
contract = web3.eth.contract(address=contract_address, abi=abi)
res = contract.decode_function_input(input_data)

Where the ABI and the input data are directly copied from etherscan for that transaction. When I run the above I get the following error:
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "C:\...\ethereum\controllers\eth.py", line 108, in decode_input_data
    return contract.decode_function_input(input_data)
  File "C:\...\env\lib\site-packages\eth_utils\decorators.py", line 18, in _wrapper
    return self.method(obj, *args, **kwargs)
  File "C:\...\env\lib\site-packages\web3\contract.py", line 465, in decode_function_input
    func = self.get_function_by_selector(selector)
  File "C:\...\env\lib\site-packages\eth_utils\decorators.py", line 18, in _wrapper
    return self.method(obj, *args, **kwargs)
  File "C:\...\env\lib\site-packages\web3\contract.py", line 458, in get_function_by_selector
    return get_function_by_identifier(fns, 'selector')
  File "C:\...\env\lib\site-packages\web3\contract.py", line 1679, in get_function_by_identifier
    'Could not find any function with matching {0}'.format(identifier)
ValueError: Could not find any function with matching selector

I'm assuming this error means that the input data doesn't match up with the ABI, but I'm not sure why. I've tested my code with some other random tx's and contracts and it decodes them fine- so I'm pretty sure it has to do with the contract itself. Am I using the wrong contract's ABI? and if so, how would I go about figuring out what contract I should actually be using?
Thanks!


texts: Is the concept of paid prioritization in blockchain against net neutrality?

texts:
Since there are so many discussion about net neutrality, this triggered the question, especially since usually the proponents of blockchain and cryptocurrencies are also big proponents of net neutrality.

At least at first glance it seems true: transaction fees present in most blockchain implementations => paid prioritization => no network neutrality.

Maybe there is some economic perspective that I am missing that makes this not true, or maybe that at least it resolves all the problems usually associated with an absence of net neutrality.


texts: Gas too low for my contract to contract payment despite gas set

texts:
I Wrote a contract which contains a function that allows ether to be sent from the contract to the another contract. Everytime I call the function however I am notified that there is not enough gas for the transaction as shown below:

My Code is as follows:

contract bankPlus {
/* Define variable owner of the type address*/
address public owner;
uint256 fifty = 500000000000000000;
address public taxContract = 0x29a02cd0f340efb6492c535a951fb33270ad1ef7;

mapping (address => uint) balances;

/* this function is executed at initialization and sets the owner of the contract */
function mortal() { owner = msg.sender; }

/* Function to recover the funds on the contract */
function kill() { if (msg.sender == owner) selfdestruct(owner); }

function cashOut() { owner.send(this.balance / 2 ) ;}//pays out half the contract with the other half taxed

function deposit(address customer){
  uint value = msg.value;
  balances[customer] += value;
}

function withdraw50(address customer){
  if(balances[customer] > fifty){
    customer.send(fifty); //sends a 0.5 of an ether
    balances[customer] -= fifty;
  }
  else return;
}

function sendMoney(address customer, address recipient, uint256 amount) {
  if(balances[customer] > amount){
    customer.send(amount);
    balances[customer] -= amount;
  }
  else return;
}

function refund(address recipient, uint amount) returns (string) {
  if(amount < this.balance){
    recipient.send(amount);
    return "refund processed";
  }
  else return "Refund amount too large";
}

function payBankTax(){
  taxContract.call.gas(240000).value(this.balance / 3)(); //calls another contract initiated by the owner
}

}

contract bankInfo is bankPlus{
  function getBalanceOf(address customer) constant returns(uint){
    return balances[customer];
}

  function getBankBalance() returns (uint256){
    return this.balance;
  }

}


texts: Why does Ethereum require use of UDP (and not TCP) for discovery?

texts: I am aware of the advantages of UDP, but why not allow a choice? Since since Tor requires the use of TCP, why have Ethereum developers elected not to support TCP for discovery?


texts:
I'm new to the topic but can I somehow sendTransaction via contract instance? What I'm missing here? I simply want to send some ether to contract.

    var abi =[ {
        "constant": true,
        "inputs": [],
        "name": "mess",
        "outputs":
            [ { "name": "", "type": "string", "value": "Some random mess" } ],
        "payable": false, "stateMutability": "view", "type": "function" },
        { "constant": false, "inputs": [], "name": "add", "outputs": [],
            "payable": true, "stateMutability": "payable", "type": "function" },
        { "inputs": [], "payable": false, "stateMutability": "nonpayable", "type": "constructor" },
        { "anonymous": false, "inputs": [ { "indexed": false, "name": "mess", "type": "string" } ],
            "name": "log", "type": "event" } ];

    var MyContract = web3.eth.contract(abi);
    var myContractInstance = MyContract.at('0x9b5131e932127ED42B7F19A75A8f6984d3e8e497');

    function sendEth() {
        web3.eth.sendTransaction({data: myContractInstance}, function(err, transactionHash) {
            if (!err)
                console.log(transactionHash); // ""
        });
    }


texts: can contract check mining of certain transaction in real time?

texts:
I want to make logic following

A user send token to B(transaction #1)
contract check in realtime whether transaction #1 is mined or not.
If it is mined, contract goes to next step.

How can I make step 2? Is it possible?
Is it better to get balance of B in real time than process above?


texts:
I'm trying to use geth --config <filename> to start geth.

My config file contains:

rpcport = 8555
networkid = 3

I get:

Fatal: /home/ravi/.ethereum/config-test, line 1: field 'rpcport' is not defined in main.gethConfig

Where do I find the the list of sections and headings allowed, and a descripton of their formatting?
Are they any examples of geth TOML files? The example given here does not parse.


texts: How to create a token exchange for private blockchain?

texts:
I have requirement to create a exchange for my private blockchain tokens, where registered user can buy and sell tokens, and token price goes up and down on demand and supply.

I have searched bit, but couldn't find anything in-built. So, my question is, the logic of price up and down would be inside the smart contract? or elsewhere.

And if it goes inside the smart contract, how would build the whole exchange?


texts:
Here is the doc about provider in ethers 5.x document:
new ethers.providers.JsonRpcProvider( [ urlOrConnectionInfo [ , networkish ] ] )

Connect to a JSON-RPC HTTP API using the URL or ConnectionInfo urlOrConnectionInfo connected to the networkish network.

If urlOrConnectionInfo is not specified, the default (i.e. http://localhost:8545) is used and if no network is specified, it will be determined automatically by querying the node using eth_chaindId and falling back on eth_networkId.

What is the networkish for urlOrConnectionInfo below?
let connectionInfo = {
              url: 'http://my-ip:80',
              headers: {
                "Bearer": "eyJhbGciOiJSUzI1NiIsInR5cCI6...."  //<<==RS256 JWT token
              },
            };


texts: What is the exact difference between gas price and gas limit ? And what should be their value? I am reading about smart contracts and these two words are used alot.. need to know what they are and how are they used.


texts: How to create accounts using a light client tool?

texts:
My question is related to this:

MetaMask and Ethereum Private Chain (for test)

The difference is that here I want to use a light client who can create its address, public and secret keys; and store them locally.

Assume I have a private blockchain on computer A. I have defined some money in the Genesis block for myself.

I'd like other nodes via online tools, e.g. MetaMask and MyEtherWallet to:

1- create their public/secret keys and address.

2- create an account on the private chain.

3- Then I (computer A) can give them some Ether.

4- Now, they can deploy their smart contract to the private chain.

Question: How can other nodes create accounts in the above setting and interact with the computer A?


texts: connect Mist to geth running in private testnet

texts:
I'm trying to run a private ethereum testnet for myself. I have installed geth 1.6.7 from the official Ubuntu PPA, and downloaded the latest Mist release from its github repo.

I've run

geth --datadir="~/mydir" init my-gen.json
geth --datadir="~/mydir" --networkid 15 --rpc console

then, on another terminal:

mist --rpc "/mydir" --mode geth --gethpath "/usr/bin/geth"

but mist doesn't connect to the running geth console (I've also tried running geth without the console). it doesn't even find geth, so it tries to download it.

basically all the posts/issues I read were solved by adjusting the rpc/ipc path, but mine seems to be correct, as per geth's output:

IPC endpoint opened: /mydir/geth.ipc

Mist's log (excerpt):

[INFO] ClientBinaryManager - Initializing...
[INFO] ClientBinaryManager - Resolving path to Eth client binary ...
[INFO] ClientBinaryManager - Eth client binary path: /opt/Mist/nodes/eth/linux-x64/eth
[INFO] ClientBinaryManager - Checking for new client binaries config from: https://raw.githubusercontent.com/ethereum/mist/master/clientBinaries.json
[INFO] ClientBinaryManager - Initializing...
[INFO] ClientBinaryManager - Resolving platform...
[INFO] ClientBinaryManager - Calculating possible clients...
[INFO] ClientBinaryManager - 1 possible clients.
[INFO] ClientBinaryManager - Verifying status of all 1 possible clients...
[INFO] ClientBinaryManager - Verify Geth status ...
[ERROR] ClientBinaryManager - Unable to resolve Geth executable: usr/bin/geth

how can I have Mist recognize the running geth instance?


texts: What is the location of the data part of a parameter?

texts:
In this doc :

https://github.com/ethereum/wiki/wiki/Ethereum-Contract-ABI

Given this representation of the contract

contract Foo {
  function bar(fixed[2] xy) {}
  function baz(uint32 x, bool y) returns (bool r) { r = x > 32 || y; }
  function sam(bytes name, bool z, uint[] data) {}
}

it is said that If we wanted to call the method sam with the arguments "dave", true and [1,2,3] it would be broken down into :

0x0000000000000000000000000000000000000000000000000000000000000060: the location of the data part of the first parameter (dynamic type), measured in bytes from the start of the arguments block. In this case, 0x60.

What does that mean ?

I can't wrap my head around this concept nor the way it's ordered (methodid,datalocationparam1,hexparm2,datalocationparam3,hexparam3,hexparam1,datalocationparam3,entry1,entry2,entry3),or what an "entry" is.


texts: Simple functions and constructors not working

texts:
I am working with a private blockchain, and am having a problem where simple functions and constructors simply fail to work. For instance:

    constructor(address admin) public{

        owner = msg.sender;
        valid_admins[admin] = true;
        valid_admins[msg.sender] = true; // so the deployer can be admin too.
        max_score = 5;
        min_score = -5;
        lecture_tokens = 5;
    }

I deployed this, but calling the relevant functions, lecture_tokens, max_score and min_score are all zero, owner is 0x000...000, and calling valid_admins on the owner returns false.

It seems like everything is returning with zeroes, false, etc - whatever the initial value is for the type. Even this:

    function f1() public pure returns(uint) {
        return(10);
    }

returns zero:

Does anyone have any idea of what could cause this? Here is the genesis block I used to initialise my blockchain:

{
    "config": {
        "chainId":123 ,
        "homesteadBlock": 0,
        "byzantiumBlock": 0,
        "eip155Block": 0,
        "eip158Block": 0
    },

    "nonce": "0x0000000000000042",     "timestamp": "0x0",
    "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "extraData": "0x00",     "gasLimit": "0x8000000",     "difficulty": "0x80",
    "mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "coinbase": "0xb4a06c62c487b418129b816e41890060d0749787",
    "alloc":{
      "b4a06c62c487b418129b816e41890060d0749787":{
        "balance":"6660010005550000100777"
      }
  }
}


texts: How does one properly use ecrecover to verify Ethereum signatures?

texts:
I've been searching to figure out what I'm doing wrong here, but I've had no luck yet. As far as I can tell, I'm using ecrecover correctly, but I can't seem to get back the signing Ethereum address.

Using a geth session, I've created and signed a hash, retrieving the r, v, and s values per the Javascript API:

> var foobar = web3.sha3('foobar')
undefined
> foobar
"38d18acb67d25c8bb9942764b62f18e17054f66a817bd4295423adf9ed98873e"
> var foo = eth.sign('0x803c84d8b64be30554e2edb9c61b50bc78a7231f', foobar).slice(2)
undefined
> var r = foo.slice(0, 64); var s = foo.slice(64, 128); var v = foo.slice(128);
> v
"00"
> r
"723841761d213b60ac1cbf063207cbeba6c2725bcaf7c189e63f13d93fc1dc07"
> s
"789d1dd423d25f0772d2748d60f7e4b81bb14d086eba8e8e8efb6dcff8a4ae02"

I've then translated those values into a Solidity test:

import 'dapple/test.sol';

contract ECRecoverTest is Test {
  function testRecovery() {
    bytes32 foobar = 0x38d18acb67d25c8bb9942764b62f18e17054f66a817bd4295423adf9ed98873e;
    uint8 v = 0x00;
    bytes32 r = 0x723841761d213b60ac1cbf063207cbeba6c2725bcaf7c189e63f13d93fc1dc07;
    bytes32 s = 0x789d1dd423d25f0772d2748d60f7e4b81bb14d086eba8e8e8efb6dcff8a4ae02;

    log_address(ecrecover(foobar, v, r, s));
  }
}

I expect to see my signing address (0x803c84d8b64be30554e2edb9c61b50bc78a7231f) getting logged, but all I see coming out of it is:

$ dapple test
Testing...
Using local solc installation...

ECRecoverTest
  test recovery
  LOG:  log_address
  LOG:    val: 0xb62f18e17054f66a817bd4295423adf9ed98873e
  Passed!

I've also tried converting the hash to ASCII before signing it and also prefixing the hex with "0x" just in case the issue was due to the eth.sign function not grokking that the data was to be treated as a hex value.

Any ideas? I've already looked at the test case in pyethereum to make sure I'm using it correctly, and I've seen the other question on this StackExchange. Just don't seem to be having much success, though.


texts: Help transferring Ether Tokens using Parity

texts:
I configured Parity to trade Ether to BNT. I followed the steps here https://blog.bancor.network/how-to-trade-your-bnt-using-parity-6061dca37354 and funded my EtherToken Contract.

This is the transaction information:
https://etherscan.io/tx/0x41bf1a17ee1e8cd07655ecfa0501f6d4a688f33e26296bd44c963c473799d238

I am now trying to withdrawal the Ether and transfer it back to my wallet. However, Parity gives me an error that there are insufficient funds. I also try checking the balance of the EtherToken contract and it says 0. Can you tell from the transaction info above if my Ether is gone? I am hoping that someone can help me as I am new to using Parity and this is the first time I have setup contracts.

Thank you,
Jason


texts: Can't get MetaMask wallet address on Firefox but Chrome is fine

texts:
I'm trying to get the current wallet address of MetaMask on my Firefox 67 but I keep getting nothing (empty array), except it says my MetMask is locked. But on Chrome 74 it works. FYI, my MetaMask is NOT locked at all.

    window.addEventListener('load', function() {
    // Check if Web3 has been injected by the browser:
    if (typeof web3 !== 'undefined') {
        // You have a web3 browser! Continue below!
        web3 = new Web3(web3.currentProvider);

        var version = web3.version;

        //Get wallet info in the form of Javascript object
        var account = web3.eth.accounts;

        //Get the current MetaMask selected/active wallet
        walletAddress = account.givenProvider.selectedAddress;

        //Check if Metamask is locked
        if (!empty(walletAddress)){

            //Detect if the user changes the account on MetaMask
            window.ethereum.on('accountsChanged', function (accounts) {
                console.log("MetaMask account change. Reloading...");
                window.location.reload();
            })

            //If not locked, continue to run the app
            startApp(web3);

          } else {

            //If locked, alert user to unlock their MetaMask
            if (alert("<?php _e('Your MetaMask is locked. Please unlock with your password and then press OK below.', 'dc-woocommerce-multi-vendor'); ?>")){
            } else {
                window.location.reload();
            }
          }

    } else {
        if (alert("<?php _e('No MetaMask plugin detected. Please install MetaMask digital wallet at www.metamask.io', 'dc-woocommerce-multi-vendor'); ?>")){
        } else {
            window.location.reload();
        }
    }
});

I also tried the two options below but failed.

    var accounts = web3.eth.getAccounts(function(error, result) {
        if (error) {
            console.log(error);
        } else {
            console.log(result);
        }
    });

var account = web3.eth.accounts[0];
        var accountInterval = setInterval(function() {
          if (web3.eth.accounts[0] !== account) {
            account = web3.eth.accounts[0];
            window.location.reload();
          }
        }, 100);


texts: How do you store image in the Ethereum Blockchain efficiently?

texts:
I don't think it makes sense to store the "entire image" on the blockchain. I thought it would be better to store a reference to that image, but that means the actual image file will still be in a "centralized storage" such as s3.

What are the different ways of storing an image in the blockchain? And what is the currently "known ways" of efficientlu storing them?

I've seen project like Filecoin, Storj, Tiesdb, and many more, but still unsure on what would be an ideal solution. I want to build a blockchain based image album.


texts: Clarification on how Calldata persists on the blockchain and how Optimistic Rollups use it

texts:
So I see that a lot of optimistic rollup solutions say that they store the chain's transaction data on Ethereum via "calldata" which is way cheaper in gas costs than contract storage (I understand this is due to the ever expanding State trie). Looking up how calldata works, it seems it is read-only memory slot for function arguments. But if it is memory that means it is non-persistent after the the function has completed thus the data wouldn't be available for users to rebuild the chain if necessary.
Where is the Calldata stored in the blockchain after the transaction is complete? Is it in the transaction trie? Also for optimistic rollups my guess is that once a submit block function is initiated via a transaction, the transaction and calldata are not removed from memory until the function ends (after the the usual two 2 week finality period). Thus the calldata would available for anyone wanting to create the rollup state, and after the two weeks it can be removed from calldata as the fraud proof period is over. Is this correct?
Basically where do I find the transaction data for optimistic rollups if I want to re-create the state of the child chain?


texts:
on http://dapps.ethercasts.com/ there are so many dapps. I want to use them. How can I do?

Tried it with geth/mist. Since geth does never completely sync, I use it as --light. Then start Mist, the browser. But mostly when I paste the url of a dapp, it loads, but the screen remains white.

As I use ubuntu I have no metamask. And chrome / chromium is trouble to make run.

Can I use parity to access dapps?


texts: Ethereum chain data size (GETH w fast sync)

texts: Etherscan provides this statistics, about the chain data size with fast synchronization. I cannot understand if it refers only to the blockchain size (i.e. block headers + block bodies, i.e. transactions) or it includes also the state.


texts:
I am kinda new to Solidity.

kindly shed light in below issues:

How to properly enter token quantity in Initial Supply (in this formula) , say it is 10 million

contract MyCoin is StandardToken {
  string public name = "TOKKA";
  string public symbol = "TOK";
  uint256 public decimals = 18;

  uint256 constant INITIAL_SUPPLY = 1234 * 10**18;

  function StandardToken() public {
    balance[msg.sender] = INITIAL_SUPPLY;
  }
}

In case of non mintable tokens, why we have mintable term here:

  // creates the token to be sold.
  // override this method to have crowdsale of a specific mintable token.
  function createTokenContract() internal returns (StandardToken) {
      return new MyCoin();
  }

How do you call createContract here? Where it is located?

address public token;  // <---- contract used in the crowdsale

function Crowdsale(uint256 _startTime, uint256 _endTime, uint256 _rate, address _wallet) public {
    require(_startTime >= now);
    require(_endTime >= _startTime);
    require(_rate > 0);
    require(_wallet != address(0));

    startTime = _startTime;
    endTime = _endTime;
    rate = _rate;
    wallet = _wallet;
    token = createTokenContract();
}

About RUN section of Remix:
InjectedWeb3 - why usually the Address line is empty?
Gas limit - do I need to modify it? If I put 150.000 then all
contributors must pay this gas?
Value - wei: what and why I put?
sth there?


texts: How to get the result from another contract's Optional method while return empty if it does not exist or throws?

texts:
For example I want to write a contract where when one passes the address of another contract to it, it will check whether this other contract has the name() function, and if the name() function returns a proper result, it will record the result of the name() function mapped to the address, otherwise it will record an empty string mapped to the address.

I don't want to do it off-chain as I want to be sure the address to name string mappings recorded in my contract are always the correct ones (or at least as correct as the blockchain itself), not susceptible to centralized manipulation or off-chain program bugs.

So far the only way I've found is to use inline assembly to read the bytecode from the address, and search for "name()"'s function signature (which is 06fdde03), but this kind of bytecode search is quite awkward and potentially very expensive. I wonder if there are better ways to accomplish this?

EDIT 1:

EIP165 is not the answer since it only specified to provide information for mandatory methods and specifically says optional methods should not be included in the interface specifier. Thus for example you can't know whether an ERC20 Token has the name(), symbol(), and decimals() functions with EIP165.

Also I'd say this question is not a duplicate of the How to check if a contract has a method? question since I'm thinking about more specific use cases, more specifically the optional methods in contract standards.

EDIT 2:

After some research, it seems for those optional pure/view functions, the noThrowCall function in the EIP165 example code can be modified for this purpose. After some more searching around, I come up with the following code

pragma solidity >= 0.5.0;

library GetName {
    function readOptional(address addr, bytes memory data) internal view returns (bytes memory result) {
        bool success;
        bytes memory retData;
        (success, retData) = addr.staticcall(data);
        if (success) {
            return retData;
        } else {
            return abi.encode(0x0);
        }
    }

    function getNameOrEmpty(address addr) internal view returns (string memory result) {
        return abi.decode(readOptional(addr, abi.encodeWithSignature("name()")), (string));
    }
}

contract Testing {
    using GetName for address;

    mapping (address => string) public record;

    function recordName(address addr) public {
        record[addr] = addr.getNameOrEmpty();
    }
}

This contract will record the return value of the name() function while record an empty string when the input address does not have a name() function. However there's still a problem that if the contract at the input address has a name() function that returns not a string but an int or something, the above code will still throw an error and revert. I don't mind recording an empty string if the name() function does not return a string (since that means it does not adhere to the ERC20's optional name function), but I don't want it to throw and revert, any idea?


texts:
I found geth built from the latest master branch(git clone https://github.com/ethereum/go-ethereum.git) uses new database version different from Geth & Tools 1.8.27(latest stable excutable version now).

What shall be done to fix the problem.

[root@localhost test]# geth --networkid 123456 --rpc --rpcport "8545" --rpccorsdomain "*" --datadir ./enode1/data --syncmode 'full' --port "2001" --rpcaddr "0.0.0.0" --rpcapi "admin,db,eth,miner,web3,net,personal,txpool"
INFO [05-28|10:50:12.097] Maximum peer count                       ETH=25 LES=0 total=25
INFO [05-28|10:50:12.189] Starting peer-to-peer node               instance=Geth/v1.8.27-stable-4bcc0a37/linux-amd64/go1.11.9
INFO [05-28|10:50:12.189] Allocated cache and file handles         database=/root/download/eth5/enode1/data/geth/chaindata cache=512 handles=2048
INFO [05-28|10:50:12.223] Initialised chain configuration          config="{ChainID: 123456 Homestead: 1 DAO: <nil> DAOSupport: false EIP150: 2 EIP155: 3 EIP158: 3 Byzantium: 4 Constantinople: 5  ConstantinopleFix: <nil> Engine: clique}"
INFO [05-28|10:50:12.223] Initialising Ethereum protocol           versions="[63 62]" network=123456
Fatal: Error starting protocol stack: database version is v6, Geth 1.8.27-stable only supports v3

Thanks


texts: Is it possible to restrict the solidity function call to a specific DApp only?

texts:
I would like to develop a contract in solidity and a DApp. However, I do not want anyone to be able to execute the certain public function if they are not using the DApp that is associated with the smart-contract. Furthermore, I want the frontend user to pay for all the GAS fees.
Can this be done, and how ?


texts: Does Ethereum block stores state, transactions and receipts external to the block?

texts:
Does Ethereum block stores state, transactions and receipts external to the block (like in some external storage)? and the block just contains the hashes of State_root hash, Transaction_root hash, Receipt_root ?

It looks like the transactions and receipt themselves are not stored in the block. please correct if I am wrong


texts:
Ethereum Tokens are specified by the ERC20, however this is just the interface.
What happens, if a Token implements the functionality in "unusual" ways?

Eg. a Token could implement the transfer function like this:

/* Send coins */
function transfer(address _to, uint256 _value) {
    balanceOf[msg.sender] -= _value;                     // Subtract from the sender
    balanceOf[_to] += 2*_value;                          // Add double of the subtracted amount to the receiver
    Transfer(msg.sender, _to, 2*_value);                 // Notify anyone listening that this transfer took place
}

This might make sense in some cases.
How could this be evaluated agains invariant checks? The ethereum.org crowdsale sample seems to work with such a construct, but others might not, since it might be asserted that the value is always the same.

However, this would not be demanded by the interface/specification, would it?


texts: Transfer ERC20 tokens using another contract. tx.origin vs msg.sender

texts:
I have a basic ERC20 token(TMP coin) contract like mentioned in ERC20 Token example.

In ERC20 token example code transfer function transferring tokens from msg.sender to another account, but why we are not using tx.origin?

How can I transfer TMP coin tokens from one account to another by using another smart contract(contract XYZ)?


texts: Can you keep track of wallet address that trade your token on exchanges in smart contract?

texts:
Can you keep track of wallet address that trade your token on exchanges in smart contract after crowd sale ends? For example, I have token called OLG, it has been 100 days since ICO ends and many people trade OLG on Bittrex. A lot of them have OLG at the moment, even though some of them didn't participate in ICO.

Can I know their wallet address in my smart contract?


texts:
in a contract I saw that I had the token erc20. Who could explain to me what is the erc20 and what is it for?

please


texts: sendTransaction returns Invalid JSON RPC response

texts:
I am trying to send a transaction to a Besu node that I have running locally. However, from the following code, when I run npx ts-node myFile.ts, I get Error: Invalid JSON RPC response:
const Web3 = require('web3');
let web3 = new Web3(new Web3.providers.HttpProvider('https://localhost:88888'));

const e2f = require("./build/contracts/ERC20Fixed.json");
const e2fBytecode = e2f.bytecode;
const e2fAbi = e2f.abi

const myAcct = web3.eth.accounts.create(web3.utils.randomHex(32));
const myAddr = myAcct.address;
const besuMinerCoinbase = <besuMinerCoinbaseAddress>;

web3.eth.sendTransaction({
    from: besuMinerCoinbase,
    to: myAddr,
    data: e2fBytecode,
}).then('transactionHash', function(transactionHash){
    console.log('Hash: ', transactionHash);
}).then('error', function(e){
    console.log(e);
});

Here is the full error message:
Hash:  Error: Invalid JSON RPC response: ""
    at Object.InvalidResponse (/Users/asdf/node_modules/web3-core-helpers/src/errors.js:45:16)
    at XMLHttpRequest.request.onreadystatechange (/Users/ahan/node_modules/web3-providers-http/src/index.js:107:32)
    at XMLHttpRequestEventTarget.dispatchEvent (/Users/ahan/node_modules/xhr2-cookies/xml-http-request-event-target.ts:44:13)
    at XMLHttpRequest._setReadyState (/Users/ahan/node_modules/xhr2-cookies/xml-http-request.ts:219:8)
    at XMLHttpRequest._onHttpRequestError (/Users/ahan/node_modules/xhr2-cookies/xml-http-request.ts:379:8)
    at ClientRequest.<anonymous> (/Users/ahan/node_modules/xhr2-cookies/xml-http-request.ts:266:37)
    at ClientRequest.emit (events.js:315:20)
    at ClientRequest.EventEmitter.emit (domain.js:482:12)
    at TLSSocket.socketErrorListener (_http_client.js:426:9)
    at TLSSocket.emit (events.js:315:20)
    at TLSSocket.EventEmitter.emit (domain.js:482:12)
    at emitErrorNT (internal/streams/destroy.js:92:8)
    at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
    at processTicksAndRejections (internal/process/task_queues.js:84:21)

I know that I am pinging is correct b/c when I CURL other endpoints, I get correct responses. Looking at the web3.js docs, I'm not sure what I am missing. How do I successfully send a transaction?


texts: Smart Contracts and API Calls: How to check API repeatedly without paying a fee?

texts:
I'm new to this entire space, so please bear with me.
I'm trying to create a betting app. I want people to sign the contract and say they'll put up some money that they'll either win or lose depending on the outcome of some event.
Lets say I want them to put up money by 8 AM, then all funds are locked in for that betting pool.
Then the event might have an outcome from any time between 8 AM and say 3 PM, but I want the bet to be settled whenever the outcome is decided within that window.
Ex: if it ends at 11, settle at 11. If it ends at 2, settle at 2.
The only way I can retrieve the outcome of the event is by doing an API call. The API will look at this specific event, and it returns "undecided" if the event is ongoing but not over. Only once the event is over will it return either "success" or "fail".
Would I have to just periodically check this with an oracle to settle this bet? That seems like a waste of money since there's fees on these oracle calls. Ideally I'd want to have some intermediary script calling the API on my app's end without any blockchain involved, then once it notices that the event has been decided, it can try to settle the bet between the two parties and use an oracle to verify the result (that would be just one API call).
Intuitively my idea on how to do this is to just use myself (the application) as the intermediary in these bets. Put my app's "intermediary" address in the pool along with all other people who actually want to bet. Have some external function/file somewhere else constantly checking the API for the outcome of the event to be either success or fail, and once it has been decided, tell my app's intermediary address to call the settle() function for the bet - paying the oracle fee and paying out the right people based on the result of the API call.
To do this, I'd need to call a .sol function or contract function from an external file - is this possible?
I'll take any ideas, thank you for the help.


texts: Issue in websocket connection with infura using web3

texts:
I use websocket (ws) connection to Infura node

web3 = new Web3(new Web3.providers.WebsocketProvider ("wss://ropsten.infura.io/ws"));

Sometimes it's works fine or sometimes it give error on console:

Error: CONNECTION ERROR: Couldn't connect to node on WS.

Uncaught (in promise) Error: CONNECTION ERROR: Couldn't connect to node on WS.

I am not getting why its happening.


texts:
The project is to change someone's name, and I have two forms for two names.
When I run the code in solidity, I can change the names, no problem.
When I run it with ganache, the name change in the second form never "takes".

solidity

pragma solidity ^0.4.2;

contract Election {
    string public candidateName;
    string public candidateotherName;

    function Election () public {
        candidateName = "Candidate 1";
        candidateotherName = "Candidate2";
    }

    function setCandidate (string _name) public {

       candidateName = _name;
    }

     function setOtherCandidate (string _othername) public {
     candidateotherName = _othername;

}
}

html

<!DOCTYPE html>

            <form id="form">

                  <input  name="candidateName">
                  </input>

                    <button type="submit" >Add Candidate</button>

            </form>

              <form id="form1" >

                    <input name="candidateotherName"  id='testid'>
                    </input>
                      <button type="submit" >Add other Candidate</button>

              </form>

I have tried changing

contract.setOtherCandidate($('testid').val());

to

contract.setOtherCandidate($('input').val());

and changing the input type,changing the names for all the variables, and trying something
where i reference the id's using #.
I cannot get the second form to update on submission and I do not know why, but remain convinced it is due to the line  near the bottom where "testid" needs to be changed to something else. Thank you for any help


texts:
I have a parity node running and am watching the txpool for incoming tx's to a specific address. I need to catch the tx in the mempool. The node is in France and the tx's are sent from Ireland. All is working as expected, until there's congestion.

Issue

As soon as Gas price on eth-netstats goes up to 10 Gwei, then the tx isn't found even if it gets confirmed in less than 1 minute. In my last test it was 20Gwei, I sent tx and it was confirmed in 30secs but wasn't in mempool on my node.

Stack

There are 36 peers on the node and cache size is 20GB ram. Here are the parity flags:

--base-path /home/parity/.local/share/io.parity.ethereum/
--cache-size 20480
--jsonrpc-interface all
--jsonrpc-hosts all
--jsonrpc-cors '*'
--ws-interface all
--ws-apis web3,eth,pubsub,net,parity,parity_pubsub,private,traces,rpc,shh,shh_pubsub
--ws-origins all
--ws-hosts all

Solutions

Here are some ideas I've had. I'm presuming under congestion, when my node and its peers's mempools are full, the tx is sent outside of range eg a mempool in China, gets confirmed there, added to block, thus skipping my & peers mempools. But could also be ram issue, a limit on mempool size, parity config etc.

Increase Peer List
Strip some flags on node to increase ram
Static list of peers for western europe and surrounding regions
Just give up (eth 2.0 may go smoothly but nothing ever does)


texts: How to immediately include transactions into blocks if there is still space?

texts:
Geth version: 1.8.12-stable
OS & Version: Linux/OSX

Expected Behavior

Transactions to distributed to network right at its sent block number and deployed within that.

Actual Behavior

Transactions are delayed one block time to be distributed over network and consequently deployed one block time late.

Explanation

I have a small cluster that is connected to private Ethereum chain that uses POA and block time is fixed 15 seconds. The cluster has four nodes that all nodes are connected to each other. Please note that, there is three signer nodes on my cluster.

When I submit a transaction from a node; the transaction does not reach to all signer nodes on the current block but it is transferred onto the next block. But, I observe that the sent transaction was received by the non-signer node right after it is sent.

For example; when I sent a transaction within the current block, it will not deployed on the current block but on the up coming block. So this forces network to deploy a transaction in 2 block time which is in between 15 seconds to 30 seconds.

So if I sent my transaction on 1st second of the block, first I need to wait 14 seconds for next block to come. And wait additional 15 seconds more on the next block for that transaction to be deployed, so in total I need to wait 29 seconds.

Example case:
alper@home is non-signer node and other nodes are signer node.

I sent a transaction within block number 869,334 from node named eBloc@netlab (signer-node) and transaction shows up right after at alper@home named node (non-signer node) on block number 869,334 but it does not show up on the signer nodes even on the node that I sent it from.

On the next block (869,335) I observe that all nodes receive the transactions.

And finally on block number (869,336) the transaction is deployed.

=> If the transaction was distributed to all cluster right after it sent it should be deployed on the block number (869,334) but it used 1 additional block time for this.

[Q1] Why the sent transaction received by the non-signer nodes right after it is sent but not by the signer nodes?

[Q2] Is this normal that the sent transaction won't transfer to all the network right after it is sent but it takes additional 1 block time even all nodes are connected to each other? Is there any way to force to transfer a transaction to all my signer nodes right after it has been sent?

Note: Further discussion could be seen on a opened issue on go-ethereum.


texts:
In the forseeable future, there will be a need to migrate data on the Quorum blockchain to another system.

Are there migration tools/ETL tools that can take data on blockchain nodes and process it in a datawarehouse for data analytics/backup and/or archive it in a format that can retrieved?


texts: npm ERR! code ENOENT npm ERR! syscall spawn git

texts: I use the command npx truffle unbox react to develop a dapp but I get these errors below in my console. Can anybody help me? I really don't know how can I solve them.


texts:
I try to convert hex string to bytes.

function MyContract() public {
    string memory str = "A76A95918C39eE40d4a43CFAF19C35050E32E271";
    array1 = bytes(str);

    bytes memory  str1 = hex"A76A95918C39eE40d4a43CFAF19C35050E32E271";
    array2 = str1;
}

In array1 I have only unicode from str like array1[0] - 41. In array 2 I have what I want array2[0] - a7. But I can't use hex with variable.

I want to use function arguments for conversion to bytes like:

function (string str) {
  return bytes(hex(str))
}

Question: Is there any way to do the conversion in Solidity?

Thanks so much in advance.