texts: A problem with filters and events (web3j/TestRPC). SOS! ;)

texts:
Help me, please, with this little simple task! I cannot solve this problem for several days. SOS! ;)
I'm trying to write a program for filtering events via web3j. I copied to start (for the test) from somewhere this simple contract:

pragma solidity ^0.4.11;
contract EventTest {
  event NumberEvent(uint indexed number);

  function triggerEvent(uint val) returns (uint) {
    NumberEvent(val);
    return 123;
  }
}

Then I ran TestRPC, Remix, and created a contract. Here is the state after that:

C:\>testrpc
EthereumJS TestRPC v3.0.5

Available Accounts
==================
(0) 0x5403bdee62d577b2660a2a6af4590ce9c426aceb
(1) 0x88302f871bb26f044f106f1f686fba4f07d9658d
(2) 0xd90aedb12243b420b63317936acaff289316bad6
(3) 0x537598e72b2b8cd179f3fc72ef09f7233f73ef44
(4) 0xef571d65c0e828da5091bb76169dc7ca0ff67f15
(5) 0xe251fa32bf822ad3ccb3133d97ccd64ab97cb0fd
(6) 0x20d6a6bd42ba577a1e6fa938f738b0e07191021b
(7) 0x8e76d16288f5068d2406f1cb7005df449a88790a
(8) 0xb05b5df33972324edc49c02d23ec710f31fc3d09
(9) 0x1bb116bd5916ba749caa429d08406d57030d2eb6

Private Keys
==================
(0) fbd2033e842b85c0da50d1ebc0a73deae130c887762116937ad60266a974c3dd
(1) 6fa1c314f48bb9dee169cb3d6e4d9348adb7df82fefa5229349e8aa3ebc7ce02
(2) 0995cc564f136217a7438daab9f55ca3e593e67483f36de5862826b52f264b19
(3) f642805c48f3c9fda4fac90df031ad0836a4701263d1c900f1d5b42e3b073b51
(4) d4b868c78ee8af1c7900a9a2f6ae59042ef26038aeb151f03a010547852bc99a
(5) 9f76d96f9d88e078591f38ae0d249a746287814fb0f95e59b8634165a1b71560
(6) 722f6fbbd74b471e0ab294983401abb1aecabd6e1e4584eba99c2f408b75c9e3
(7) a57e22386e8874834535e2dd02c28ef8123e7412ff6896d273e0cac69553fe81
(8) 28a53adc37ffa7e96615b0b2e20fb7f342dc99aed2d0e681ca9a447cc5101f05
(9) b92a329c6f616af0bfe7f20d9a48e5518d5ede352475eab640a555300029a7d9

HD Wallet
==================
Mnemonic:      bird ship unlock fiber drink kiwi surprise warrior over cereal item poet
Base HD Path:  m/44'/60'/0'/0/{account_index}

Listening on localhost:8545
eth_accounts
eth_accounts
eth_estimateGas
eth_getBlockByNumber
eth_sendTransaction

  Transaction: 0xc9b39a4ee3c3d02ef4a76011b3bdc00721f196e90e6b9a6708c8d9842ca03698
  Contract created: 0x53417664007120b53005a9f1a42b3fb02e6cb0c7
  Gas usage: 0x01a9f1
  Block Number: 0x01
  Block Time: Thu May 04 2017 12:08:19 GMT+0200

eth_getTransactionReceipt
eth_newFilter
eth_getFilterLogs
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges

Since in the command line from TestRPC approximately every second the message "eth_getFilterChanges" appeared, I closed the browser with Remix and then the new messages "eth_getFilterChanges" ceased to arrive.

Then I launched such Java code to "listen" to new events from this my test contract.

import org.web3j.protocol.Web3j;
import org.web3j.protocol.core.DefaultBlockParameterName;
import org.web3j.protocol.core.methods.request.EthFilter;
import org.web3j.protocol.core.methods.response.Log;
import org.web3j.protocol.http.HttpService;

import rx.functions.Action1;

public class Subscribe {

    public static String contractAddr = "0x53417664007120b53005a9f1a42b3fb02e6cb0c7";

    public static void main(String[] args) {

        Web3j web3 = Web3j.build(new HttpService());

        EthFilter filter = new EthFilter(DefaultBlockParameterName.EARLIEST, DefaultBlockParameterName.LATEST, contractAddr);
        web3.ethLogObservable(filter).subscribe(new Action1<Log>() {
            @Override
            public void call(Log log) {
                System.out.println("log.toString(): " + log.toString());
            }
        });
    }
}

Here is the result:

eth_newFilter
eth_getFilterChanges
FilterSubprovider - no filter with that id: 0x2

Could you please explain what I'm doing wrong?
Thank you in advance for any help!


texts: using  re-renders the component infinitely

texts:
I'm trying to build a simple dapp using drizzle-react's 'DrizzleContext'. This is how my index.js file looks like:

import React from 'react';
import ReactDOM from 'react-dom';
import { Drizzle, generateStore } from "drizzle";
import { DrizzleContext } from "drizzle-react";
import './index.css';
import App from './App';
//import * as serviceWorker from './serviceWorker';
import drizzleOptions from './drizzleOptions';

const drizzleStore = generateStore(drizzleOptions);
const drizzle = new Drizzle(drizzleOptions, drizzleStore);

ReactDOM.render(
    (<DrizzleContext.Provider drizzle={drizzle} >
        <App />
    </DrizzleContext.Provider>), document.getElementById('root'));

Also, this is how my  component looks like:

import React from "react";
import { DrizzleContext } from "drizzle-react";

    export default () => (
        <DrizzleContext.Consumer>
            {drizzleContext => {
                const { drizzle, drizzleState, initialized } = drizzleContext;

                if (!initialized) {
                    return "Loading...";
                }

                console.log("value of initialized: ");
                console.log(initialized);

                return (

hello world

                );
            }}
        </DrizzleContext.Consumer>
    )

turns out that using < DrizzleContext.Consumer > tag starts re-rendering the complete state infinitely, as is evident in the console log where all the mentioned logs keep repeating. Is this normal behavior ? Is there a way we can arrest this infinite re-render inside a Functional Component ?


texts: How recuperate a result returned by calling a function of another contract

texts:
I want to recuperate a result returned by a call to a function of another contract in my contract.
My solidity code is bellow, I have

contract A {
    function verifyUser(address userAddress) public returns(bool) {
        bool verified = false;
        uint id = userId[userAddress];
        if (id != 0) {
            verified = true;
        }
        return verified;
    }
}

I used the assembly code to get the returned value of the verifyUser method of contract A

 contract B {
function verifAtt(uint idRequiredData, uint P, address userAddress) public returns (bool answer){
    answer=false;
    if(P==1) {
                bytes4 sig = bytes4(keccak256("verifyUser(address)"));
                assembly {
                    // move pointer to free memory spot
                    let ptr := mload(0x40)
                    // put function sig at memory spot
                    mstore(ptr,sig)
                    // append argument after function sig
                    mstore(add(ptr,0x04), userAddress)

                    let result := call(
                      15000, // gas limit
                      sload(dc), // to addr. append var to _slot to access storage variable
                      0, // not transfer any ether
                      ptr, // Inputs are stored at location ptr
                      0x24, // Inputs are 36 bytes long
                      ptr,  //Store output over input
                      0x20) //Outputs are 32 bytes long
                    if eq(result, 0) {
                       revert(0, 0)
                    }
                    answer := mload(ptr) // Assign output to answer var
                    mstore(0x40,add(ptr,0x24)) // Set storage pointer to new space
                }
            }
        }
return answer
}

I tested the function verifyUser of contract B and the result is always true even if the result must be false.
I want to be sure that the assembly code is right.

I work with remix and solidity 0.4.16


texts: Why some transaction errors lead to discarding the whole block?

texts:
In terms of go-ethereum code, transaction errors can be grouped into (I made up the terminology) several categories by their effect on state transition.

System errors: like database connection issues. These, understandably, lead to cancelling the whole state transition. Retry follows.
Contract errors: like stack overflows or out of gas. These lead to reverting the transaction progress, still applying the gas fee and other post-processing, and proceeding with the next transactions.
Consensus errors: like invalid transaction nonce or unsuccessful balance transfer (only the initial one; doesn't apply for any following nested "insufficient balance for transfer"). These errors lead to discarding the whole state transition and marking the block invalid.

The question is why category (3) needs to be so fatal that the whole block would be rendered invalid? Intuitively seems like those are still "client" errors that could be scoped to the individual transactions, allowing the others to be executed.


texts: How to convert public key (64 bytes) to compressed public key (33 bytes)

texts:
I currently have a generated 64-byte public key that has been recovered from an Ethereum transaction.
How do I convert this key into a 33-byte compressed public-key? The problem I'm having seems pretty trivial but I cannot for the life of me find a solution! I'm currently working with javascript.
Any help would be greatly appreciated.


texts: etherwallet-3.4.2 on private chain invalid sender error

texts:
In order to use etherwallet in private chain setup, I completed following Use Your Own Server Guide, answer_1 and  answer_2. I have added Custom Node and MyEtherWallet works , except sometimes it requires refreshing the page if there is disconnection with the node.

As an example, I can see my correct account balance, where I verified the value also in geth.

When I tried to send a transaction to a valid account address on my private blockchain, I have faced with the following error: invalid sender.

[Q] What may be the reason of this error and how can I fix it? I am able to complete this transaction inside geth.


texts: Ethereum Consortium Blockchain Designed to be Proof of Concept or Production Ready

texts:
Is the Ethereum Consortium Blockchain template in Azure merely designed as a proof of concept platform or is it something you would use for production?

I ask this because if I deploy the Ethereum Consortium Blockchain in my Azure account; am I not technically serving as the "centralized" player in the blockchain since its running in my account, thus defeating the purpose of blockahin?

When reading the description of the template; it states this: This solution deploys an Ethereum simulated multi-member network, consisting of a set of load-balanced transaction nodes with which an application or user can interact to submit transactions and a set of mining nodes to record transactions.

Is this blockchain designed to allow outside nodes to work against it or do all the node VMs have to remain within my azure account?

I certainly appreciate the speed and ease Microsoft has made with creating this template; I just want to try and understand if I wanted to have a production, blockchain that say multiple large clients want to use; this would be the template I would need to use or if I would have to build out something completely different.

Thanks!


texts: where is the presale.wallet available to import?

texts:
I am very new to ethereum community, just started setting up ethereum in my machine hoping to mine some ether.

I have downloaded and run geth.exe, created a new account.

My next step according to link i am following is importing a presale.wallet file

  https://github.com/ethereum/go-ethereum/wiki/Managing-your-accounts

My question is how do i do that? where can i find it?

I tried just giving some path hoping it will download it but got the following error

  Fatal: Could not read wallet file: read
  C:\Users\Username\AppData\Roaming\Ethereum: The handle is invalid.

please help me solve this. And any links or tips on how to effectively mine will be helpfull.

Thanks in advance,
Mahesh


texts:
Dear valuable partners,

I am crypto-fun, not an expert. From and living in Benin.

I want to create my own cryptocoin on Ethereum Blockchain. Below are my questions about that:

How can I proceed?
How much shall I spend for in total?
Is it possible to hire Crypto-Techo Experts to help me ? For how
much?
May you provide me with a full PDF documentation about all the
procedures?

THANKS SO MUCH


texts: Solidity compile Expected token Comma got 'Identifier'

texts:
I'm trying to compile a contract in the solidity browser compiler and get this error:

  Expected token Comma got 'Identifier'
              person.setRent(uint256 _rent);

What is the token Comma in this case?

My contract:

contract Landlord is user {
    string public landlordName;
    string public physicalAddress;
    function Landlord(
        string _name,
        string _physicalAddress){

        landlordName = _name;
        physicalAddress = _physicalAddress;
    }

    function setRent(uint256 _rent, address _tenantAddress){
        Tenant person = Tenant(_tenantAddress);
        person.setRent(uint256 _rent);

    }


texts: Remix Solidity Smart Contract Stuck On Compiling State

texts:
The 1inch Smart Contract is unable to compile in Remix as it appears to be stuck in the Solidity compiling phase.
Expected

Create a new 1inch_38211317.sol smart contract file in Remix.
Compile the contract.
Deploy and run the contract on the Ropsten Test Network.

Observed

The 1inch Smart Contract code is copied into a new 1inch_Test.sol file.
The default compiler version throws an error.

browswer/1inch_38211317.sol:782:1: ParseError: Source file requires different compiler version (current compiler is 0.7.4+commit.3f05b770.Emscripten.clang) - note that nightly builds are considered to be strictly less than the released version pragma solidity ^0.6.0

Change the compiler to the latest local version - 0.7.4

The Compile 1inch_38211317.sol button is stuck in the compiling/loading state.


texts: how to check if account is unlocked via JSON RPC

texts: How would one validate if ethereum account is locked/unlocked via JSON RPC ?


texts: How can I send some message from contract to address

texts:
Is it possible? And if it is, how can I send some data from contract to address.
Something like

msg.sender.send.data("0x0")(value)


texts:
so I've been working on ethereum for the past few weeks, mainly deploying and interacting with contracts but something i noticed is the high gas usage of using the tokens over time, so i was wondering if there may be a way to save the gas for users who would use my contract? like is there a way that a contract may pay its own fees? if I give it enough ether ofcourse... I want to be able to let users with 0 ether use my contract, any help or direction would be much appericiated! :)

thanks for your help.


texts: Why does an empty message still invoke the code of the contract?

texts:
An empty message still invokes the code of the contract and is the mechanism that allows Solidity to implement a feature of a fallback function per contract.

But when msg.data is empty, why does contract code still need to execute?

If a caller leaves msg.data empty, meaning they don't want to pass any data or call any functions at all on a contract, why does the contract code still need to run?


texts:
I tried to run the code in http://dapps.oraclize.it/browser-solidity/#version=soljson-v0.4.24+commit.e67f0147.js but I get the error VM: out of gas when I try to run the updatePrice function. I set the value of 0.05 ether when running the function and deploying the contract.

I have tried running it in injected web3(rinkeby testnet) in remix, the updatePrice function runs but the __callback is not called. Did it according to https://medium.com/coinmonks/simple-oraclize-example-with-solidity-68b6811902da.

Tried running the dieselPrice.sol from the oraclize site in remix.ethereum.com with JavaScript VM. But this yields:

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

when running updatePrice with 0.05 ether as the set value.


texts: Sending a transaction - can I assume that when the 'data' field is missing, the 'gas' field should always be 21000?

texts:
I have implemented a function for transferring ETH from my account to another account:

async function transfer(to, value) {
    let options = {
        from : PUBLIC_ADDRESS,
        to   : to,
        value: value
    };
    options.gas = await web3.eth.estimateGas(options);
    let signedTransaction = await web3.eth.accounts.signTransaction(options, PRIVATE_KEY);
    return await web3.eth.sendSignedTransaction(signedTransaction.rawTransaction);
}

This is purely for ETH transfer; I am not trying to invoke any smart contract function, so I can omit the data field from the options object.

I've noticed that web3.eth.estimateGas(options) always returns 21000.

Can I count on that, and simplify my code to:

    let options = {
        from : PUBLIC_ADDR,
        to   : to,
        value: value,
        gas  : 21000
    };

?

Thanks


texts: How Can I Get the Gas Cost of Contract Creation *within* Truffle (Migrations/Test)

texts:
When running truffle migrate or truffle test, how can I get the gas usage (for example, see below the log from testrpc)?

Transaction: 0x19d38e8d8418db2bcc569068ad756adf10edd77c39c2da1afd4639b30efdbe31
Contract created: 0x7589cbcd1d32fb4b6bac489453c58395c4cea3ff
Gas usage: 4308473 // <=== HOW DO I ACCESS THIS IN TRUFFLE?
Block Number: 14
Block Time: Sun Jan 14 2018 16:11:54 GMT-0800 (PST)

For example, if I had the transactionHash, I could just use web3.eth.getTransactionReceipt and check receipt.gasUsed.

I can not access the receipt since the instance of the Contract.deployed() does not have a transactionHash.

Is there a way to access the equivalent of receipt.gasUsed for a contract deployed by Truffle?


texts: Hello, I am totally new in this I was copying code for deflationary crypto token, and getting syntax error I can't fix

texts: I am totally new in this I was copying code for deflationary crypto token, and getting syntax error I can't fix, I can send whole code if necesarry I am not sure if I should paste it here.


texts: Ethereum Wallet takes forever to sync every day I open it. Is this practical?

texts: Does anyone agree that it is impractical to wait so VERY LONG every time I open my Ethereum Wallet and hit has to sync? What's up with that? Solutions?


texts:
I was able to successfully able to deploy smart contract but the Transaction receipt status is fail. I am posting the link https://ropsten.etherscan.io/tx/0x6a9f66eefaaf349043c96310879d99f02a393ff7b180962af7e856bf18c2ea1a
I think maybe there is some problem with gas price.
what should minimal gas price for an smart contract


texts: How to connect from Remix to Kovan testnet?

texts:
In Remix, there is a Contracts tab, where I can choose the "Execution environment". When I choose "Web3 Provider", I am asked to provide the "Web3 provider endpoint". What should I write there in order to connect to the public Kovan testnet?

(I hope the question makes sense... I am entirely new to Ether)


texts:
I am stuggling with memory explosion issue of Parity on my EC2 instance.
The memory usage of it keeps increasing gradually.

I suspect that getLogs API call makes some garbage on the node. But I couldn't get similar issue report from anywhere. Furthermore, I am not a Rust developer that can find the issue from the code.

I call getBlock, estimateGas, sendRawTransaction, etc, besides getLogs. But no filter related calls.

Could you tell me whether the calls made the memory explosion or there is any other reason? Anyone suffered from the same issue on Parity?


texts: web3j: EthSendTransaction.sendTransaction() is throwing "Error processing transaction request: Invalid params: invalid format"

texts:
I am trying to send a transaction to an address: 0xDD210......... using the EthSendTransaction.sendTransaction() method from the org.web3j.protocol.core.methods.response.EthSendTransaction library.

The transaction contains data but doesn't have any value (I don't have to send funds). I am using the private network(localhost: 8545)

The syntax is:

EthSendTransaction transactionResponse = transactionManager.sendTransaction(220000000,
            43000, "0xDD210......", hashedData.toString(), BigInteger.valueOf(0));

String transactionHash = transactionResponse.getTransactionHash();

The value of transactionHash is null.

if (transactionResponse.hasError()) {
        logger.info("in error block");
        throw new RuntimeException(
                "Error processing transaction request: " +
transactionResponse.getError().getMessage());

On runtime, the code gives

  "Error processing transaction request: Invalid params: invalid hex."

Does anyone know the solution to this?


texts: Transfering MATIC tokens on matic network

texts:
I'm attempting to transfer MATIC on the matic testnet (mumbai) and submitting the standard ERC20 transfer call (0xa9059cbb) isn't working.  Here's my transaction:
0xa9059cbb000000000000000000000000accountnumberhere00000000000000000000000000000000000000000000000000071afd498d0000
When I send this to dummy ERC (0xaeea34b61f7f6c5c49dbea1383c0de496fed859c678772e5e13fdaae4db187f4), it transfers DERC tokens to the recipient.  When I send it to MATIC (0x0000000000000000000000000000000000001010), it instead shows as a successful transfer of 0 MATIC to the MATIC account, and no transaction or MATIC shows on the recipient account.
Is there a different ABI that I need to be using for transfering MATIC than other ERC20 tokens?


texts: If someone found a private key to 0x0, would they be able to access all the tokens (over one billion dollars worth) stored there?

texts: The 0x0 address in Ethereum has a lot of token stored in it that have been burnt in the past.  However, it appears they burning is the same as sending to 0x0.  In that case, could all of those burnt tokens be recovered if someone had access to the private key for 0x0?


texts:
I'm soo deep inside the consensus protocols like PoW, PoS, PoA or other variants used on permissioned/private blockchains such as JPMorgan's Quorum (Based on Raft), Istambul etc..

But I've not entered yet on the Hyperledger consensus protocols and it's implementations specifications and differences.

So my questions are:

What is the consensus protocol used on Hyperledger?
It's inherited from any of the mentioned above?
Which are the main differences between it's variants (Fabric, Iroha, Sawtooth, and Indy)?

Please, it'll be fantastic if useful documentation links/articles/lectures were added with the answers.

Thanks.


texts: How can we connect two truffle applications with each other? E.g., if we have two metacoin applications, how can these two communicate with each other?


texts: What actually happens to contract storage?

texts:
Supose I Have a contract like

contract foo{

    bytes32[] bar;

    function set(bytes32 _foo) {
        bar.push(_foo);
    }
}

So if i deploy the contract what will happen 1st.
And for every time when i call set() will the whole bar array need to be writen in chain or only the newest element will be writen in chain as a transaction.
Now if i hav a getter for bar then how it will return the all element of that array?


texts:
I found a pre-existing question for this topic here, but I am still not clear on the answer so I am asking the question in a slightly different way:

  Is Ethereum a single blockchain, or a framework for building
  blockchains?

I am still learning all about blockchain and my understanding is that the biggest value proposition is that I can make transactions with anyone else in the world, but I assume that this needs to occur on the public block-chain which is why I am confused; why would anyone want a private blockchain? Is it the goal of Ethereum to create a single blockchain, or is the magic more in the fact that it is a framework for creating private blockchains?

Thanks in advance!


texts: How to recover account and keystore file?

texts:
I am using go-ethereum and web3.

Is there any way to recover an account if the keystore file is lost?
Is there any way to recover an account in case of forgotten passphrase?


texts: I am using the ethereum wallet on xubuntu 17.04. I have been using geth --fast --rpc to sync since geth --light will not connect to peers. I got this error for geth --fast --rpc syncing


texts: Why ETH has value and what is the floor for it?

texts:
I've been happily on my journey down the crypto rabbit hole over the last few months of quarantine. I've personally bought into the narrative that Bitcoin excels as a digital store of value, and as such its price is driven by the human need for a stable, tamperproof, fixed supply asset in order to preserve value as well as measure value consistently over time. In this function, Bitcoin is compared to digital gold.
I've recently begun looking into Ethereum. I've listened to several talks now where they've said something like, "Bitcoin is digital gold, Ethereum is digital oil." Now, obviously digital oil is valuable. I've learned that the Ethereum network is a distributed os capable of running distributed applications. Its scripting language is Turing complete, and the development community is thriving and likely the most active within the smart-contract-crypto universe. What I fundamentally do not understand is how purchasing and holding ETH is an investment in that growing network.
The gold vs oil analogy seems rather apt. In the case of Bitcoin, since the lifetime supply of Bitcoin is capped, as Bitcoin realizes its store of value function, the value of a Bitcoin should approximately be equal to all the value that humans are trying to store in Bitcoin divided by the number of Bitcoins.
In the case of Ethereum, ETH is used to pay the network to run applications. Each operation has a fixed cost expressed in Gas, and there is a changing exchange rate to convert between ETH in Gas. Furthermore, the supply of ETH is not fixed, and is subject to change. Given these facts, I do not understand how purchasing ETH is an investment in the future of Ethereum. It seems to me that over time, the price of an ETH will approach the real world cost of executing the number of operations you can run on the Ethereum network as determined by the Gas - ETH exchange rate. Even if we assume that Ethereum will grow and establish itself as the dominant distributed processor blockchain, why would the price of ETH ever go above the price of the function the network is providing? AKA, why would it go above the cost of the electricity that is being consumed plus the hardware cost to run whatever application you're running via ETH?


texts: Why does Uniswap computes amountOut of a token this way?

texts:
It seems[1] they do:
(0.997 * amountIn * reserveOut) / (reserveIn + 0.997 * amountIn)
From my understanding it should be amountIn * price, which with fee becomes ((1 - fee) * amountIn) * price.
Now, since price is given by reserveOut / reserveIn, and since fee = 0.003, the above becomes (0.997 * amountIn * reserveOut) / (reserveIn)
We're missing the whole second addendum at the denominator!
Where is that coming from?

References
[1]: Directly from the contract:
function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) internal pure returns (uint amountOut) {
    require(amountIn > 0, 'UniswapV2Library: INSUFFICIENT_INPUT_AMOUNT');
    require(reserveIn > 0 && reserveOut > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
    uint amountInWithFee = amountIn.mul(997);
    uint numerator = amountInWithFee.mul(reserveOut);
    uint denominator = reserveIn.mul(1000).add(amountInWithFee);
    amountOut = numerator / denominator;
}


texts: Parity: Function in derived contract not working

texts:
Working with the Parity client and web3 Javascript API on a private chain, I tested the following code:

pragma solidity ^0.4.7;

contract simple {
    function twice(int a) constant returns(int) {
        return 2*a;
    }
}

The above code was compiled and deployed with the following Javascript code:

var compiledSimple = web3.eth.compile.solidity(<source>);
var contractSimple = web3.eth.contract(<ABI>);

contractSimple.new( { from: <fromAddress>, data: compiledSimple, gas: "0x493e0" },
    function(err, contract) {
        if (err) {
            console.log('ERROR: ' + err);
            return;
        }
        if (!contract.address) {
            console.log('Address to be assigned... txnHash: ', contract.transactionHash);
        }
        else {
            console.log("Simple contract DEPLOYED at address: " + contract.address);
        }
    }
);

Now, I could call the function twice(int), which returned the correct result i.e. the input integer doubled.

Then, I modified the code to the following:

pragma solidity ^0.4.7;

contract owned {
    address owner;
    function owned() {
        owner = msg.sender;
    }
    function getOwner() constant returns(address) {
        return owner;
    }
}

contract simple is owned {
    function twice(int a) constant returns(int) {
        return 2*a;
    }
}

After deploying this with the same Javascript code, I find that I can call getOwner() and get the correct <fromAddress> that was specified when contract was deployed. However, calling twice(int) always returns 0, whatever the input value may be. It looks as if only the base contract got deployed, and not the derived contract.

Here is the ABI specified when deploying the later code:

var ABI_SIMPLE = [
  {"constant":true,
   "inputs":[{"name":"a","type":"int256"}],
   "name":"twice",
   "outputs":[{"name":"","type":"int256"}],
   "payable":false,
   "type":"function"},
  {"constant":true,
   "inputs":[],
   "name":"getOwner",
   "outputs":[{"name":"","type":"address"}],
   "payable":false,
   "type":"function"}
];

Am I missing something here? Really appreciate any help.

EDIT: Code calling the contract

Here is the code that calls the contract function twice(int). It is part of a NodeJS application, and ABI_SIMPLE (given above) and ADDRESS_SIMPLE are defined as constants outside the code block below. HTTP request has header Content-Type: application/json:

var invokeSimple = function(req, res) {
    var inVal = parseInt(req.params.input);
    var simple = web3.eth.contract(ABI_SIMPLE).at(ADDRESS_SIMPLE);
    var result = simple.twice(inVal);
    res.status(200).send({result: result});
}


texts: I have some SALT tokens held on an EthAddress.org paper wallet. I want to move them to my Exodus wallet but when I type the private key in (I have triple checked that I enter it correctly) it gives an error message saying there are not enough funds? I have checked my public address on Etherscan and it shows the tokens are there. Can anyone help please?


texts: Smart Contract overview ERC-20 instead of ERC-721

texts:
I have created ERC-721 standard but on etherscan (Ropsten) it's still showing ERC-20 standard in overview
Below are my contract code, please share your thought if I'm doing something wrong.

contract ERC721Token {

 function name() external view returns (string memory);
   function symbol() external view returns (string memory);
   function totalSupply() external view returns (uint256);
   function balanceOf(address _owner) external view returns (uint balance);
   // Functions that define ownership
   function ownerOf(uint256 _tokenId) external returns (address owner);
   function approve(address _to, uint256 _tokenId) external returns (bool success);
   function takeOwnership(uint256 _tokenId) external returns (bool success);
   function transfer(address _to, uint256 _tokenId) external returns (bool success);
   function tokenOfOwnerByIndex(address _owner, uint256 _index) external returns (uint tokenId);
   // Token metadata
   function tokenMetadata(uint256 _tokenId) external returns (string memory infoUrl);
   // Events
   event Transfer(address indexed _from, address indexed _to, uint256 _tokenId);
   event Approval(address indexed _owner, address indexed _approved, uint256 _tokenId);
}

contract TestToken is ERC721Token {

  string  public name;
  string  public symbol;
  uint8   public decimals;
  uint256 public totalTokens;
   mapping(address => uint) private balances;
   mapping(uint256 => address) private tokenOwners;
   mapping(uint256 => bool) private tokenExists;
   mapping(address => mapping (address => uint256)) private allowed;
   mapping(address => mapping(uint256 => uint256)) private ownerTokens;

  constructor(
        uint256 _totalTokens,
        string memory _tokenName,
        uint8 _decimalsPoints,
        string memory _tokenSymbol
        ) public {
        balances[msg.sender] = _totalTokens;
        symbol = _tokenSymbol;
        name = _tokenName;
        decimals = _decimalsPoints;
        totalTokens = 100000000 * (10 ** uint256(decimals));
        emit Transfer(address(0), msg.sender, totalTokens);
    }

   function totalSupply() public view returns (uint256){
       return totalTokens;
   }
   function balanceOf(address _owner) public view returns (uint){
       return balances[_owner];
   }
   function ownerOf(uint256 _tokenId) public returns (address){
       require(tokenExists[_tokenId]);
       return tokenOwners[_tokenId];
   }

  function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
    require(balances[_from] >= _value && allowed[_from][msg.sender] >= _value);
    balances[_to] += _value;
    balances[_from] -= _value;
    allowed[_from][msg.sender] -= _value;
    emit Transfer(_from, _to, _value);
    return true;
  }

  function approve(address _spender, uint256 _value) public returns (bool success) {
    allowed[msg.sender][_spender] = _value;
    emit Approval(msg.sender, _spender, _value);
    return true;
  }

  function takeOwnership(uint256 _tokenId) public returns(bool success){
      require(tokenExists[_tokenId]);
      return true;
  }

  function transfer(address _to, uint256 _value) public returns (bool success) {
    require(balances[msg.sender] >= _value && balances[_to] + _value > balances[_to]);
    //require(_to != 0x0);
    balances[msg.sender] -= _value;
    balances[_to] += _value;
    emit Transfer(msg.sender, _to, _value);
    return true;
  }
  function tokenOfOwnerByIndex(address _owner, uint256 _index) public returns (uint _tokenId) {
      return 5;
  }
  function tokenMetadata(uint256 _tokenId) public returns (string memory infoUrl) {
     require(tokenExists[_tokenId]);
     return "ss";
  }
}


texts: Invoke smart contract by address, from another contract

texts:
I'm trying out a publisher-subscriber smart contracts in ganache.

Both the publisher and subscriber work independently, but when I try to invoke the subscriber from publisher through the contract address, I get below error:

  "Error: VM Exception while processing transaction: revert".

Been searching on the net, but didn't find any solution.

Here is my code:

  Producer.sol

//Mocking subscriber contract

contract Receiver {

function notify(uint count) returns(uint);

function getCurrentCounter() constant returns(uint);

}

//Publisher

contract Producer {

uint private count;
uint private subscriberCount;
mapping(uint => Subscriber) subscribers;
event CountIncreased(uint num);

struct Subscriber {
    string subscriberName;
    address subscriberAddress;
}

function Producer() {
    count = 0;
    subscriberCount = 0;
}

function increaseCount() returns(uint,address) {
    count++;
    Receiver receiver = Receiver(subscribers[0].subscriberAddress);
    receiver.notify(count);
    CountIncreased(count);
    return (count,subscribers[0].subscriberAddress);
}

function addSubscriber(string name, address subAddress) {
    subscriberCount++;
    subscribers[subscriberCount].subscriberName = name ;
    subscribers[subscriberCount].subscriberAddress = subAddress ;
}

function removeSubscriber(string subscriberName) {
    for (uint i=0; i<subscriberCount; i++) {
        Subscriber sub = subscribers[i];
        if(keccak256(sub.subscriberName) == keccak256(subscriberName)) {
            delete subscribers[i];
            subscriberCount--;
        }
    }

}

}

  Subscriber.sol

pragma solidity ^0.4.0;

contract Bookkeeping {

uint counter;

function Bookkeeping() {
    counter = 0;
}

function notify(uint count) returns(uint) {
    counter = count+5;
    return counter;
}

function getCurrentCounter() constant returns(uint) {
    return counter;
}

}


texts: MyEtherWallet The DAO withdraw is stuck, can I continue manually?

texts:
I believe the withdrawal process for my test amount of DAO to be withdrawn to Ether got stuck after the approval function, it now shows 0 amount of DAO but Ether didn't increase.
Can I manually resume, i.e. invoke the next function or is it going to be more complicated than that?

This is the address in question: 0xC4Da809d8071704F01B403b781877E4A0Feef01D


texts: What are the safest wallets for receiving and storing Ether from an ICO?

texts:
Is it safe to use something like MyEtherWallet to set up a wallet and use that address in your crowdsale contract to receive funds from an ICO (thousands of ether)?

If not, what is the recommended process for safely setting up a wallet and receiving large amounts of ETH?


texts: Verifying transactions for payment using ERC20 on our own PHP payment gateway

texts:
We want to create a token ERC20 on Ethereum and build our PHP payment gateway for our customers to pay us with our new ERC20 token.

Some questions:

Is there a way to verify the transactions without running our own node?
If we do require our own node, can we install this on our dedicated Linux box?
If the node is required, I assume we can check our node for the transactions. Is that how it works?


texts:
I try to deploy a big contract with 800 lines on private network of geth,but the geth report an error:
The contract code couldn't be stored, please check your gas amount. undefined

This is my document of creation block :

{
  "config": {
        "chainId": 10,
        "homesteadBlock": 0,
        "eip155Block": 0,
        "eip158Block": 0
    },
  "coinbase"   : "0x0000000000000000000000000000000000000000",
  "difficulty" : "0x20000",
  "extraData"  : "",
  "gasLimit"   : "0xffffffff",
  "nonce"      : "0x0000000000000042",
  "mixhash"    : "0x0000000000000000000000000000000000000000000000000000000000000000",
  "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
  "timestamp"  : "0x00",
  "alloc": {}
}

This is the method I initialize the network:

geth init "//home/lsg/Desktop/LSG/./genesis.json" --datadir "//home/lsg/Desktop/LSG/./DN"

This is the method I start geth:

geth --identity "LSG"
--rpc
--rpccorsdomain "*"
--datadir "//home/lsg/Desktop/LSG/./DN"
--port 30303
--nodiscover
--rpcapi "db,eth,net,web3"
--networkid 999 console 2>>//home/lsg/Desktop/LSG/DN.log

I can deploy small contract with 400 lines successfully .But the geth report a error:  "The contract code couldn't be stored, please check your gas amount."when I deploy my big contract,

Did I make a mistake or does geth not support big contract?


texts: The "Fisherman" idea for indirectly determining the validity of the canonical chain?

texts:
The following article explains the problem of validating a block in a cross-shard transaction in a sharded chain, along with existing solutions.

One of the mentioned solutions is the "Fisherman" idea in which:

  "Whenever a block header is communicated between chains for any
  purpose (such as cross-linking to the beacon chain, or a cross-shard
  transaction), there’s a period of time during which any honest
  validator can provide a proof that the block is invalid."

Link to the article: https://medium.com/nearprotocol/unsolved-problems-in-blockchain-sharding-2327d6517f43

I could not find the seminal paper / article that has proposed the Fisherman idea for the first time.

Where is the article that has proposed the Fisherman idea for the first time?

Any help is appreciated.


texts: Using web3js apis for ethereum transactions

texts:
I want to use Web3.js APIs to create an Ethereum transaction from an address (not a smart contract) to another address using sendTransaction method  (https://web3js.readthedocs.io/en/1.0/web3-eth.html#sendtransaction)

Query:

Is it feasible?
If user has to provide it's private key for every transaction, wouldn't it breach the security? That is, it is possible to have multiple send transactions once private key is received.


texts: Listening for events on real time with Web3

texts:
I want to update UI elements of an app based on contract events. My problem is, that I do not receive any events that happen after the site has been loaded (seems like the subscription does not work). Here is my code (contracts are already deployed and connected via Web3):
myContract.events.MyEvent({}, function(){console.log("event triggered")});

When I specify start and end blocks like in the following, it am getting all previous event, but still do not receive any further ones that have been emitted after the page has been loaded:
myContract.events.MyEvent({fromBlock:0, toBlock: 'latest'}, function(){console.log("event triggered")});

So it seems, that the code is not permanently listening for the event. Any suggestion on how to solve this?
I am using Web3 1.3.1 and MetaMask 9.0.0


texts: Metamask not connecting to localhost "7545"

texts: After following the pet shop tutorial i cant connect my localhost to the metamask wallet i'm still get 0eth in my wallet whereas it should be 99eth after connecting. The metamask is not showing it as private network.


texts: How can I compile multiple smart contracts in a single compile.js file?

texts:
There is another post on this question but I don't find it useful enough so I thought I should ask again. In my compile.js file, I'm taking each smart contract's complied code and put it in a respective build file. I'm dealing with three contracts at the same time and using solidity 0.5.0. My compile file works for a single smart contract but it doesn't work for multiple smart contracts. My approach was to duplicate the same lines of code that were used to compile the first smart contract.
Is there a better way to improve the code below? or would putting all the contracts in a single solidity file work?
This is my compile.js
/*
Purpose: compile specific contracts and puts their output in a build file
Updates build files whenever the contracts are updated
*/
const path = require('path');
const solc = require('solc');
const fs = require('fs-extra');

// Deletes content of build folder
const buildPath = path.resolve(__dirname,'build');
fs.removeSync(buildPath);

// Read content in contracts folder
const registerContracttPath = path.resolve(__dirname,'contracts', 'Register.sol');
const source = fs.readFileSync(registerContracttPath, 'utf8');

//complie the source of the file & pull the contracts property from the compiler
// Have to use var input for solidity version 0.5.0 and up
//Register.sol
var input = {
    language: 'Solidity',
    sources: {
        'Register.sol' : {
            content: source
        }
    },
    settings: {
        outputSelection: {
            '*': {
                '*': [ '*' ]
            }
        }
    }
};
//BottleProduction.sol
var input1 = {
    language: 'Solidity',
    sources: {
        'BottleProduction.sol' : {
            content: source
        }
    },
    settings: {
        outputSelection: {
            '*': {
                '*': [ '*' ]
            }
        }
    }
};

//Tracking.sol
var input2 = {
    language: 'Solidity',
    sources: {
        'Tracking.sol' : {
            content: source
        }
    },
    settings: {
        outputSelection: {
            '*': {
                '*': [ '*' ]
            }
        }
    }
};

const output = JSON.parse(solc.compile(JSON.stringify(input)));
const output1 = JSON.parse(solc.compile(JSON.stringify(input1)));
const output2 = JSON.parse(solc.compile(JSON.stringify(input2)));

//creates build folder
fs.ensureDirSync(buildPath);

//Put output of contract in a build file
fs.outputJsonSync(
    path.resolve(buildPath, 'Register.json'),
   {
    abi: output.contracts['Register.sol']['Register']["abi"],
    bytecode: output.contracts['Register.sol']['Register']["evm"]["bytecode"]["object"]
   },
   {
       spaces: 2,
       EOL: "\n"
   }
);

fs.outputJsonSync(
    path.resolve(buildPath, 'BottleProduction.json'),
   {
    abi: output1.contracts['BottleProduction.sol']['BottleProduction']["abi"],
    bytecode: output1.contracts['BottleProduction.sol']['BottleProduction']["evm"]["bytecode"]["object"]
   },
   {
       spaces: 2,
       EOL: "\n"
   }
);

fs.outputJsonSync(
    path.resolve(buildPath, 'Tracking.json'),
   {
    abi: output2.contracts['Tracking.sol']['Tracking']["abi"],
    bytecode: output2.contracts['Tracking.sol']['Tracking']["evm"]["bytecode"]["object"]
   },
   {
       spaces: 2,
       EOL: "\n"
   }
);


texts: How to Listen to Contract Events in Drizzle

texts:
Let's take the example of the SimpleStorage contract that comes with the truffle box drizzle-box

How can we listen to the event StorageSet and console.log it to the JS console?

drizzleOptions.js

import SimpleStorage from './../build/contracts/SimpleStorage.json'

const drizzleOptions = {
web3: {
    block: false,
    fallback: {
    type: 'ws',
    url: 'ws://127.0.0.1:8545'
    }
},
contracts: [
    SimpleStorage
],
events: {
    SimpleStorage: ['StorageSet'],
},
polls: {
    accounts: 1500
}
}

export default drizzleOptions


texts: Running real smart contracts on the testnet?

texts:
Let say that hypothetically I issue a contract on the testnet that doesn't need to receive any ether. Kind of an ERC-20, but in this case users won't exchange real ethers for tokens. These tokens would be arbitrarily provided by the contract owner to each user. Having said that, users will also be able to transfer those tokens between them, paying the necessary gas with faucet ethers.

Under such scenario, why should I use the real network, and use real ethers if testnet can basically solve my needs?

What am I missing?


texts:
Is L used as a generic function in the yellow paper or does it represent something specific? The subparts are quite specific but not L as a whole. What does a collapse function mean?
Also, what does this line mean -

It shall be understood that σ[a]s is not a ‘physical’
member of the account and does not contribute to its later
serialization.

Thanks a lot.


texts: Why an address stored in one contract looks different when it's called and seen by other contract?

texts:
I'm learning Solidity and using remix IDE.

My ultimate goal is to store list addresses in one contract and then access them via another contract. But for the sake of simplicity here I consider only one address.

Problem: The address stored in T1 contract is changed when I call it and see it in T2.

pragma solidity ^0.4.4;
contract T1{
   address public a;
   function T1(){
   a=msg.sender;// here I want to store only the owner
  }
}

pragma solidity ^0.4.4;
import "./T1.sol";

contract T2{
   address public b;
   T1 t1=new T1();
   function T2(){
     b= t1.a(); // here I want to retrive whatever's stored in a, but it
   //changes
  }
}

Now if you check b, the address is different than I stored in a.

Question: How can I solve the above problem?

Note: I'd like to store the address of people who call contract T1, so I think I have to use msg.sender, not a fixed one, like 0x123.


texts: Open Zeppelin TokenTimeLock - gas required exceeds allowance (10000000) or always failing transaction

texts:
I am creating an ERC20 contract using OpenZeppelin, to lock up my ERC20 tokens for a specific period of time. I am trying to deploy this contract onto the Rinkeby test network through remix.ethereum.org. When I try to deploy this contract, I receive an error message.
gas required exceeds allowance (10000000) or always failing transaction
Does my contract have an error in it? What would cause this error? Here is my code:
pragma solidity ^0.6.0;

import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v3.1.0/contracts/token/ERC20/IERC20.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v3.1.0/contracts/token/ERC20/TokenTimelock.sol";

contract MyTokenTimelock is TokenTimelock {
    constructor () public TokenTimelock(
        IERC20(0x974338b5d2F8924eeB4169ab19cFbc7266e46254), // token
        0x002FaCf5B2e8441c7ECb4eb6dCfD9C7b46320c97, // beneficiary
        1599557854) {
    }
}

The TokenTimelock.sol code can be found here


texts:
Crypto concurrency is not legal in India. If a developer who is citizen of India  can learn and develop ethereum applications without buying Ether? If yes how ?

I just learn that there is something called "TestNets" to develop test applications, is that legal in India ?


texts: Are all eth-tokens the same with respect to speed and security?

texts:
If two tokens both are based on eth and serve the same use case, should we assume similar transaction processing speed and resistance to Byzantine faults like Sybil / 51% attacks?

For example, consider the various stablecoin attempts that use eth. Assume all achieve identical future annualized volatility (eg, are all equally stable). Do they all give identical utility to the end user?


texts: How do I pass a token as a constructor parameter for a Crowdsale contract

texts:
I am trying to modify the OpenZeppelin Crowdsale.sol contract for my own purpose and in the constructor it takes a token.

  function Crowdsale(uint256 _startTime, uint256 _endTime, uint256 _rate, address _wallet, MintableToken _token) public {

What do I need to do there? When I try passing in the name of the token contract that I am attempting to crowdsale I get

creation of Crowdsale errored: Error encoding arguments: SyntaxError: Unexpected token x in JSON at position 46

I am using remix.

I am very confused as I cannot find any examples of how this contract is actually implemented anywhere. Thank you for any help.


texts: Unknown Parameter to Push Values to Dynamic Struct Array

texts:
I am trying to use Web3.js to push values from my frontend to a dynamic struct array in my backend.

However, I am receiving an error that I need to provide a parameter to my frontend: "Unhandled Rejection (Error): Invalid number of parameters for "challenges". Got 0 expected 1!"

I have no idea what this parameter is. Would anyone happen to know what this parameter could be? My code is provided below. Help would be insanely appreciated!


texts:
When a user unlocks their private key can two things be signed at once?

such as a message as well as a transaction, where the transaction is basically just another message that is meant to be broadcast to the network

even when using a wallet like Metamask I would like only 1 popup to appear.


texts: What's the best way to monitor contract variables whilst developing?

texts: I'm running a contract locally using Truffle, is there a way I can keep track of the variables in real-time whilst interacting with it on the front-end (Web3). I guess what I'm looking for here is something similar to http://remix.ethereum.org.


texts: Node discovery: unreachable bootnode in private distributed network

texts:
I am trying to create a private distributed network using Docker containers on Virtual Machines running ubuntu.

When I run:

bootnode --genkey $KEY_FILE --writeaddress
bootnode --nodekey $KEY_FILE --addr :30301 --nat extip:$MY_IP

either on the docker container (exposing ports 8454, 30303, 30301:30301 and 30301:30301/udp) or outside of it, if I run telnet <VM-BOOTNODE-IP> 30301 I get telnet: Unable to connect to remote host: Connection refused as reponse. If I create the bootnode NOT on a docker container sudo netstat -tulpn | grep 30301 responds with

udp6       0      0 :::30301          :::*                      */bootnode

However, when I create in the container mapping the ports sudo netstat -tulpn | grep 30301 responds with

tcp6       0      0 :::30301          :::*          LISTEN      */docker-proxy
udp6       0      0 :::30301          :::*                      */docker-proxy

Either way I get the same "Unable to connect to remote host" error with telnet. I believe it is because the bootnode's address is unreachable that the other nodes cannot be discovered.

Just to be clear: I am using the same genesis file with a particular networkId and GEN_NONCE on all VMs. My nodes are using --nodiscover (discovery port = 0) and they are listening on 30303. Using verbose level 9 on the bootnode container shows no ping/pong as suggested here.


texts: ERC standard that allows sending tokens from many origins to one destination in one transaction?

texts:
I know that any kind of operation over a token is possible so long as you implement the smart contract that achieves what you desire. For example, a function multisend can be developed that allows sending to many destinations in one transaction.

But is there any ERC spec out there that defines the opposite? That is, sending a token from many addresses (if you own the private key of all of them, of course), each address containing some amount of that token, to one destination?

Thanks


texts: Why is my ether balance 0 in geth after complete sync

texts:
I setup geth on clouding server 2 weeks ago and it was synchronized already.
And I deposit some eth to my account.
By Etherscan, I can see my balance but web3.eth.getBalance always return 0.
I create account with web3.eth.personal.newAccount.
How can I fix it ?


texts: Monitoring Eth Transactions and Syncing Native Database transactions with Etherium Blockchain

texts:
Currently, I have a node.js application which interacts with geth through web sockets. I have a listener,

web3.eth.subscribe( 'pendingTransactions', function(err, result) {

    if(!err) {
        console.log(result)
    }

})
.on('data', function(transaction) {

    console.log( transaction )

}

This listener is working perfectly fine, but it gives me data whenever any unmined transaction is detected by my geth node.

I know, i can use to and from properties from the transaction details and check if this transaction belongs to my address.

However, I would like to know if there is some way by which i can automatically get pending transactions related to my wallet addresses only like in bitcoin (wallet-notify).

If not, am I thinking the right way that I will need to filter these transactions out myself?

Also, what is the best approach to monitor transactions? What if I somewhow, miss a websocket notification. Now, how can i sync my transactions native database with blockchain database?

It would be great if anybody can share his inputs/experience here

Thanks in advance.


texts: How can transaction with high gas price fail?

texts:
I am reading this article by MEW and they mention that in period of BAT token sale someone paid $6k for transaction fee:
https://kb.myetherwallet.com/gas/what-is-gas-ethereum.html, and they quote how transaction that costed $6k failed:

  That's right. Someone paid $6000+ to send a failed transaction. Ouch,
  indeed.

What was the reason he failed? did he supply too small gas price with infinite gas limit or too small gas limit with enourmous gas price?


texts: Getting this error `ValueError: {'code': -32000, 'message': 'insufficient funds for gas * price + value'}` on raw transaction send

texts:
I know for sure I have enough eth on account. Some prelims:

I am signing a raw transaction with web3.py, like so:

transaction = {
    'to': '0xSENDHEREFINALLYPLEASE',
    'value': 1000,
    'gas': 2000000,
    'gasPrice': 20000000000,
    'nonce': 0,
    'chainId': 1,
}

I am using INFURA project id env variable in conjunction with this import:

from web3.auto.infura import w3

I sign successfully and attempt to send like so:

signed_tx = w3.eth.account.sign_transaction(transaction, 0xMYPRIVKEY)
w3.eth.sendRawTransaction(signed_tx.rawTransaction)

web3.py version is: 5.10.0

And then bam this error. Any idea what might be causing it?

Running get balance on the sender address I get its balance:

w3.eth.getBalance("0xd93800B7290B37a3ac36e4cDd3F881a929acD4A3")
>> 11000000000000000

Suppose I am writing incorrect units for gas, gasPrice or value ?

2000000 * 20000000000 + 1000 < 11000000000000000

is False, thus the error?

But when I use these params, it says the transaction is underpriced, what the... how does this work

value = 1000
gas = int(2000000 / 4)
gasPrice = 20000000000


texts: What are some good alternatives to Whisper for blockchain messaging?

texts: I have been experimenting with Ethereum and I achieved good results with Whisper in a private network. The main problem though is that it is pretty slow even when nodes are running in the same computer because messages take between 300-800ms to be received. What are some faster alternatives? My requirements are to be able to send small JSON messages as fast as possible.


texts: ICO manage softcap and hardcap when accepting ETH, BTC, or even fiat?

texts:
Using a typical capped crowdsale smart contract you can control the contribution so it always stays within the softCap - hardCap range.

When the ICO accepts ETH then it's quite easy. You can just compare the total amount raised at that point and verify it's within the acceptable range e.g. 1M-20M dollars (or the equivalent amount in ETH) where the hard cap should essentially give the total supply of the token e.g. 100M

When the contribution is available with BTC and/or Fiat then I'm not quite sure how we can check whether we are within the acceptable range at that everyone will get his tokens (i.e. the sum of tokens doesn't exceed 100M).

Does anyone know how the ICO that accept ETH, BTC and Fiat deal with soft and hard cap?


texts: POST https://kovan.infura.io/MG.......... 405 () + Uncaught Error: Invalid JSON RPC response: "" with web3js and metamask

texts:
I am trying to make a website that lets someone interact with my contract(deployed through remix using metamask onto kovan) but I am getting the above error when I try a signed function. All unsigned functions work perfectly.

One problem I think is this section of code:

web3.eth.getAccounts(function (error, accounts) {
  if (error) return console.error(error)
  console.log(accounts)
})

On my website it gives an empty array, but on https://codepen.io/anon/pen/KoRWyZ it returns["0x92165d2b80974733b7115e3cbf8285e70132d9e9"].

if (typeof web3 !== 'undefined') {
  web3 = new Web3(web3.currentProvider);
  //web3 = new Web3(new Web3.providers.HttpProvider("https://kovan.infura.io/MGb05nymXluRaB7138hk"));
} else {
  web3 = new Web3(new Web3.providers.HttpProvider("https://kovan.infura.io/MGb05nymXluRaB7138hk"));
}
web3.eth.getBlock(48, function(error, result){
    if(!error)
        console.log(result)
    else
        console.error(error);
})
web3.eth.getAccounts(function (error, accounts) {
  if (error) return console.error(error)
  console.log(accounts)
})

web3.eth.defaultAccount = web3.eth.accounts[0];
var MContract = web3.eth.contract([ABI]);
var ContractIst = papyrContract.at('address');
console.log(ContractIst);

When I try to run a signed function on the contractInst I get the above error. I have tried using both wamp and heliohost(http) but neither work.


texts: Geth parameter "networkid" vs. Genesis block "chainId" config?

texts:
I have set up a private Ethereum network with a custom chainId (for example 67890) specified in the config part of the genesis.json file, did geth init genesis.json, and got the private net up and running. However then I noticed some weird things like the web3 sendTransaction doesn't work as it says invalid sender, only after I specify the chainId explicitly in the transaction json to 67890 then it can send out the transaction correctly.

So I tried some test and found out that when I run web3.eth.net.getNetworkType() it returns privatenet, but when I run web3.eth.net.getId() it returns 1. And after some fumbling, I found out that I need to add a --networkid 67890 in the geth commandline parameter for the web3.eth.net.getId() to return the correct value of 67890.

So my question is, what's the difference between specifying the networkid in geth commandline and specifying the chainId in genesis.json? I thought the networkid and chainId are one and the same, and it seems that web3 uses the value of the networkid for the default value of the transaction chainId, but somehow when I start geth without explicit networkid parameter, it will ignore the chainId config and still use 1 as default, resulting in a different networkid from the chainId.

So for an ethereum blockchain, does it really make sense for the networkid and chainId to be different from each other, or is it some kind of bug?


texts: Do Units of Gas Exist that are not Integers?

texts: What are the units of gas? Is it measured in integers or can be any real number?


texts: Ethereum Wallet 0.5.2 >Confirm Encryption Loss> message when extracting zipped folder

texts:
Trying to download Ethereum Wallet 0.5.2 mist off github and I after
downloading I click through folders and get the following message:

This occurs when I attempt to extract the compressed folders. I have read that this may be due to the originator compressing folders on a mac and extractor is using a PC but I really have no idea and I assume encryption is of paramount importance.

Can someone please let me know what is occurring and how I can go about resolving this issue and safely update to homestead and keep my crypto secure?

Thanks in advance!


texts: bootnode : relation between boot.key and enode URL

texts:
I'm deploying a bootnode using puppeth utility, but I cannot retrieve the enode url. I think I have the boot.key file generated by puppeth, but I'm not sure it's the right one.
What's the function that takes as input the boot.key and returns the enode:// ... ?
I've tested some hashing algorithms (sha512, sha3-512 ...) but none of those seem to be the good one.

Thank's in advance for your replies


texts: What is the legitimate use case of using library contract without using contract address?

texts:
Let us look at the following contract
contract LibraryA {
    function getSenderAddress() public returns (address);
    }

contract LibraryB {
    function getSenderAddress() public returns (address);
    }

contract UseCase {
    function checkToken(LibraryA a) public returns (address)
        {return a.getSenderAddress();}}

How to make sure that invocation of function checkToken only uses the address of LibraryA? Is hardcoding the address a good idea? like   function checkToken(0xab3242443c23424523 a) ? What is the design rationale for this design in solidity? Are there any legitimate use cases? How to ensure the use of the library the developer intended to use?


texts: What will be the gas price when Eth will use Proof Of Stake?

texts:
I know that the cost of a transaction is gasUsed * gasPrice.
Gas used cannot really change unless you change your smart contract code or the gas cost of EVM opcode.

So the gas price is currently 10gwei, it's almost nothing but smart contracts are getting more and more complex and even though I follow Eth news everyday and own Eth, am not willing to pay $1 to execute an action on a DAPP.

That's why I think very low transaction cost is really necessary in the future (even maybe free) for mainstream adoption.

TLDR: What will be the gas price when Eth uses Proof Of Stake ?

Thanks!


texts: Can't access to contract functions via web3.py

texts:
I have already created contract and deployed to ethereum mainnet. Now I wanna read logs. But I can't as calling print(contract_instance.address) and contract_instance.eventFilter('Transfers') show me error log. What am I doing wrong?

import web3

from web3 import Web3, KeepAliveRPCProvider, IPCProvider
from web3.contract import ConciseContract
from solc import compile_source

ADDRESS = "..."
START_BLOCK = 4551217
END_BLOCK = 4599662

contract_source_code = '''...
'''

compiled_sol = compile_source(contract_source_code) # Compiled source code
contract_interface = compiled_sol['<stdin>:CustomToken']

web3 = Web3(KeepAliveRPCProvider(host='...', port='8545'))

contract_instance = web3.eth.contract(contract_interface['abi'], ADDRESS, ContractFactoryClass=ConciseContract)
print(contract_instance.address)

transfer_filter = contract_instance.eventFilter('Transfers')

Error logs:

Traceback (most recent call last):
  File "analysis.py", line 488, in <module>
    print(contract_instance.creator())
  File "/usr/local/lib/python3.6/site-packages/web3/contract.py", line 803, in __call__
    return self.__prepared_function(**kwargs)(*args)
  File "/usr/local/lib/python3.6/site-packages/web3/contract.py", line 832, in call_contract_function
    transaction=transaction,
  File "/usr/local/lib/python3.6/site-packages/web3/utils/decorators.py", line 13, in _wrapper
    return self.method(obj, *args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/web3/contract.py", line 692, in _prepare_transaction
    fn_kwargs,
  File "/usr/local/lib/python3.6/site-packages/eth_utils/string.py", line 85, in inner
    return force_obj_to_text(fn(*args, **kwargs))
  File "/usr/local/lib/python3.6/site-packages/web3/contract.py", line 731, in _encode_transaction_data
    fn_name, args, kwargs,
  File "/usr/local/lib/python3.6/site-packages/web3/contract.py", line 660, in _get_function_info
    fn_abi = cls._find_matching_fn_abi(fn_name, args, kwargs)
  File "/usr/local/lib/python3.6/site-packages/web3/contract.py", line 624, in _find_matching_fn_abi
    raise ValueError("No matching functions found")
ValueError: No matching functions found


texts:
want to test multiple transactions which are changing state and are dependent of each other. Is that possible using geth?
Example:
(1) First transaction will send 1 eth to account a
(2) Second transaction will send 1 eth from account a to account b

Now the second transaction will fail, if they're split and tested by eth_call. Need to "group" them so state produced by transaction (1) will be used by transaction (2)


texts: Monitor another contract with smart contract

texts:
I've got two related questions:

1- Can I develop a contract that will be triggered when the transaction is sent to another contract (that is not owned by me)?

For example, every time that a Tx for cryptokitties is inserted into the blockchain, add 1 to a counter in my contract.

2- Is it possible that a smart contract will scan and retrieve the first Tx that submitted to a contract? (and after that the second and so on..)
-I know it is possible to do it "off-line". But I want to enforce it on a contract.

Thanks.


texts:
I could not find any explanation about this so I'm reverse engineering it, the 3rd tx is the most interesting,
If you look at this transaction https://etherscan.io/tx/0x33a00225ba2d73059ade4f737d2dc8f8b565ec914872242fc0189448c5b84e22 which swaps 0.3 WETH to 6,082,510.622368052762688738 THINO
you can see in the logs :
Deposit 300000000000000000 WETH
Transfer 300000000000000000 WETH
Transfer 6082510622368052762688738 RHINO
Sync with reseve0(3856933319958440611) and reserve1(72333950858248340856148449)
Swap amount0In(300000000000000000) amount1In(null) amount0Out(null) amount1Out(6082510622368052762688738)

So I'm guessing it works like this
Then first transfert event indicate what the user want to swap, and the second transfert, what he gets
But then I looked at an other transaction which was different https://etherscan.io/tx/0x5bb712b83409b6516ae48f638605191c5bd792d752190798ddede83209dcb9c8 :
So here he swaps 0.3 WETH for 624,840,188.817931 TUSK
In the logs you get :
Deposit 300000000000000000 WETH
Transfer 300000000000000000 WETH
Transfert 624840188817931 TUSK
Sync reserve0(46698654279810799) reserve1(22094803627722313771)
Swap amount0In(374092255868) amount1In(300000000000000000) amount0Out(640861732120931) amount1Out(0)

So look like it works the same way, transfert 1 is what he wants to swap and transfert 2 what he gets, but what is amount0In(374092255868) in the swap call?
And then I saw this transaction https://etherscan.io/tx/0xfc95b0c4026ab356b36076ca624d3bf49ace40bdf3ca54a91ddad0ef128330af
From Uniswap V2: Router 2To Uniswap V2: FMA 8 For 0.3 ($548.82) Wrapped Ethe... (WETH)
From Uniswap V2: FMA 8To 0x0000000000000000000000000000000000000000 For 356.737164711807397228 ($5.12) FLAMA (FMA)
From Uniswap V2: FMA 8To 0x9b7b6bbd7d87e381f07484ea104fcc6a0363df39 For 178.368582355903698614 ($2.56) FLAMA (FMA)
From Uniswap V2: FMA 8To 0x71749af1e6a25ddf6f5c9711ea46fcbebfd1fb75 For 17,301.752488522658765611 ($248.13) FLAMA (FMA)

There is actually 4 transferts before the swap
Transfert 300000000000000000 WETH
Transfert 356737164711807397228 FMA
Transfert 178368582355903698614 FMA
Transfert 17301752488522658765611 FMA
Sync reserve0(1725598126065671219938761) reserve1(29235947838414793028)
Swap amount0In(0) amount1In(300000000000000000) amount0Out(17836858235590369861453) amount1Out(0)

I checked his balance is 17301752488522658765611 FMA (third transfert)
So I'm guessing you have to read it this way :
first transfert event is the coin and its amount being exchanged
then read all transfert events untill the swap event, user will receive the last transfert event amount
Is this right?
Thanks


texts: Remix IDE Error: Different number of arguments in return statement than in returns declaration

texts:
I am trying to compile the following contract on Remix.

    pragma solidity ^0.4.24;

contract financialContracts3{

address issuer;
constructor() public{
   issuer = msg.sender;
}
modifier ifIssuer(){
   if(issuer != msg.sender){
      revert();
   }else {
        _;//underscore
   }
}
function receiveFunds( )public payable{

}
function getValue() public constant {
   return issuer.balance;
}
}

I am getting following error message:

    browser/financialContract3.sol:20:4: TypeError: Different number of
    arguments in return statement than in returns declaration.    return
    issuer.balance;

  ^-------------------^

Some body please guide me.

Zulfi.


texts:
I'm getting the following error when I try to deploy my smart contract to Rinkeby using Truffle:
Error: Unknown arguments format passed to new HDWalletProvider. Please check your
configuration and try again

Note: I haven't had any problems deploying this same contract locally using Truffle, only to Rinkeby.
Here's my code:
require('dotenv').config();
const HDWalletProvider = require('@truffle/hdwallet-provider');

module.exports = {
  networks: {
     development: {
        host: "127.0.0.1",
        port: 8545,
        network_id: "*",
     },

     rinkeby: {
        provider: () => new HDWalletProvider(process.env.RINKEBY_MNENOMIC,
        "https://rinkeby.infura.io/v3/${process.env.INFURA_API_KEY}"),
         host: "127.0.0.1",
         network_id: 4,
         gas: 4612388,
         gasPrice: 10000000000
     },
 },

 // Configure your compilers
 compilers: {
    solc: {
       version: "0.6.2",
    }
 }

}

I'm wondering if this is some sort of version issue cause I'm seeing that my previous contracts used 'truffle-hdwallet-provider', while this one is using '@truffle/hdwallet-provider'
Meanwhile, my .env file contains the following:
#MNENOMIC="word1 word2 word3, ...word12"
RINKEBY_MNENOMIC="word1 word2 word3, ...word12"
PRODUCTION_MNENOMIC="word1 word2 word3, ...word12"

INFURA_API_KEY="xxxxxxxxxxxxxxxxxxxx"

So what might be happening here? What is this  Unknown arguments format passed to new HDWalletProvider error all about?


texts: where does web3 created account go in rpc? mainnet or testnet?

texts:
i follow very simple code sample like this:

 geth --rpc --rpcapi db,eth,net,web3,personal,web3

start geth first, then:

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

var newAccount = web3.personal.newAccount("yo");
console.log(newAccount)

but it only gives me address:

0x674061cff43583883088aa95e165d638ef5566b3

and i dont know if it resides in mainnet or testnet, it also didnt give me private key?


texts: ERC721 token transfer across private contracts

texts:
Using a token based model
I have multiple privacy groups and using Quorum
P1 - Participants A and B ( Private Contract )
P2 - Participants B and C ( Private Contract )
P3 - Participants C and D ( Private Contract )
ERC721 token is created in P1. My understanding is because it is a private contract, token cannot move to P2. It will have to created again for a different group. Is my understanding correct ?


texts: TX recieved from subscribtion but not in Tx pool

texts:
I am running local Geth and I subscribe to pending transactions like this :
const subscription = web3.eth.subscribe('pendingTransactions', (err, res) => {
    if (err) console.error(err);
});

subscription.on('data', (txHash) => {
   blah blah
}

so I start receiving a stream of pending transactions.... however I caught few transactions which were broadcasted to the subscribtion, but are NOT in the tx pool pending or queued ... ( i get the pool content via txpool.content)
usually that is some old transaction from hours ago, which got stuck for low gas fee or whatsoever ...
why does this transaction not appear in the loca tx pool, BUT it gets broadcasted via the subscribtion?


texts: Understand the potential issue of miner controlled gaslimit

texts:
I am aware that smart contracts running on top of EVM can access certain system properties such as timestamp, block number, and gas limit.

I am also aware that such properties can be controlled by the miner, and one best practice is that we should be very cautious in case using such system properties.

However, my question is that, what could go wrong, if a malicious miner intentionally control the "block.gaslimit" property used by Solidity code? Is there any "real-world" attacks or threats based on that? Just want to understand more here. Thanks a lot.


texts:
I am trying to create a smart contract and I am using ganache, visual studio code and truffle for that purpose. The versions installed in my windows system are:
Truffle v5.1.49,
Solidity v0.5.16 (solc-js),
Node v12.19.0,
and Web3.js v1.2.1. However, when I include pragma solidity ^0.5.0 in my sol file I get the following error:

I have also explicitly stated the version in my truffle-config.js file, but it didn't resolve my problem.


texts:
In Truffle 4, I am performing the migration in truffle develop by using the migrate command in the console.

However it gives the error

Error: The contract code couldn't be stored, please check your gas amount.

How can the gas used be changed? I think it requires editing truffle.js? What is the name of the network created when using truffle develop which gives testrpc listening to port 9545?


texts: How to get all contracts deployed by the address, given the address?

texts:
I want to get addresses of all instances of Contract X deployed by Account Y. How can I do that?

I have to do it programmatically and fastest possible way.


texts: How to import a contract with lower Solidity version?

texts:
I want to import a deployed smart contract TetherToken and use its functions.
Solidity version of deployed contract TetherToken is:
pragma solidity ^0.4.17;
...

I want to use its functions in my own contract:
pragma solidity ^0.6.1;
import "TetherToken.sol";
contract L {
    address payable TetherAddress = 0xdAC17F958D2ee523a2206206994597C13D831ec7;
    TetherToken Tether = TetherToken(TetherAddress);
    ...
}

But Remix says:

TetherToken.sol:1:1: ParserError: Source file requires different
compiler version (current compiler is
0.6.7+commit.b8d736ae.Emscripten.clang - note that nightly builds are considered to be strictly less than the released version pragma
solidity ^0.4.17; ^----------------------^

It's important for me to use features of Solidty 0.6.x, and TetherToken also cannot be compiled by newer version of Solidity.
How can I solve the problem?
P.N: Can I use ABI Code of TetherToken instead of its source?


texts: How to pass arguments to the constructor while testing an contract using web3

texts:
I need to test my contract using web3 and ganache-cli. In my contract, I have to send an argument to the constructor function. How to do it while deploying it with web3.

factory = await web3.eth.Contract(JSON.parse(compiledFactory.interface))
    .deploy({
      data: compiledFactory.byteCode,
    })
    .send({
      from: accounts[0],
      gas: "1000000",
    });

And my contract is,

contract Factory{
    CrowdFunding[] public deployedContractAddresses;

    constructor(uint minimum) public {
        CrowdFunding newContract = new CrowdFunding(minimum, msg.sender);
        deployedContractAddresses.push(newContract);
    }

    function getDeployedContractAddresses() public view returns(CrowdFunding[] memory) {
        return deployedContractAddresses;
    }
}

I have went through this link in stack exchange, but I cannot able to solve it.


texts: Where are the variables of a smart contract stored?

texts:
we all know that we can write smart contract with solidity in ethereum such as:

 mapping(bytes32 => bytes32) private  userPasswds ;
    event RecordReturnResult(bool res);

    /// @dev new the pair of user and password to the array here
    function newPair(string user, string password)  returns (bool) {
        bytes32  sha3_user = sha3(user);
        bytes32  sha3_password = sha3(password);
        bool res = true;
        if (userPasswds[sha3_user] > 0) {
            res = false;
            RecordReturnResult(res);
            return res;
        }
        else{
            userPasswds[sha3_user] = sha3_password;
            res = true;
            RecordReturnResult(res);
            return res;
        }
    }

Where are the variables stored? For example:

    mapping(bytes32 => bytes32) private  userPasswds ;
    event RecordReturnResult(bool res);bytes32  sha3_user = sha3(user);
    bytes32  sha3_password = sha3(password);
    bool res = true;

are they stored in block chain or leveldb or other places? thank you.


texts:
I am trying to sync the Parity wallet to the Ethereum network. I keep getting this error:

    Encountered error during state restoration: IO error: /Users/pro/Library/Application
Support/io.parity.ethereum/chains/ethereum/db/906a34e69aec8c0d/snapshot/restoration/db/000339.log:
No such file or directory

I will appreciate any guidance on this.


texts: how do I know which node picks up my transaction? in general, how is a node assigned to broadcast a specific transaction?

texts: How do I know what node is broadcasting my transaction to the network? how can i get more information about this node? for example, how do i know if the node is a geth or parity node? does it matter?


texts: Difference between calling contract.function(), contract.function.call() and contract.function.sendTransaction({})

texts:
What is the difference between calling:

contract.function()
contract.function.call()
contract.function.sendTransaction({from:myaddress})

I know that contract.function.call() means a local dry run, whereas chaining sendTransaction means that it is run normally and there are side-effects on the blockchain. What about contract.function()?


texts: Can we write pure native mobile app that on blockchain

texts:
I have a web-based blockchain application. On web, I can use metamask for making transaction. On mobile, I can use some Dapp browser such as Toshi ...

But I want to write a native application (pure android/ios application). Do we have any solutions for this. I have searched but don't found any.


texts: Solidity: Choosing 5 random values of an array

texts: How can I choose 5 random values of an array, which a function will be called upon? e.g. if I have x number of participants of a party stored in an array, how can I choose 5 random participants stored in the array who will be chosen to perform some future action?


texts: Where are Geth's "fast" and "light" syncing options officially documented?

texts:
Go Ethereum's documentation for running the command line program is at https://geth.ethereum.org/docs/interface/command-line-options

There it specifies the --syncmode option with the explanation:

  Blockchain sync mode ("fast", "full", or "light")

Where are the terms "fast", "full", and "light" specified?


texts: sendTransaction() method locks running of my app

texts:
There is how I launch Geth node:

geth --fast --rpc --ipcapi= "admin,eth,personal" --rpcapi= "eth,web3,personal"

with following test-only unlocking account:

geth --exec 'personal.unlockAccount(eth.coinbase, "psw" ,0)' attach

About one-two hour(s) Geth can execute web3.eth.sendTransaction() correctly, but later on attempts to execute this fails, the method just locks either my app's running (if it is used in web3-app, even with async callback) or js-console (if it is used with JS-console). There is no any exception, just endless locking.

Additional information:

Ether is sufficiently
Account is not locked
web3.net.listening returns true
web3.eth.getBlock("latest") returns a 2-hours-outdated block

So, I see my Geth stopped sync. What can be a cause? Why do not sendTransaction() throw any exception?


texts: Is there a smart contract recording all block hashes on in the ethereum blockchain, as they come in?

texts: I'm wondering whether anyone has already made a contract and corresponding off-chain service which, once every 30 minutes or so, triggers the contract to record all the block hashes which have gone by since the last time it was called. Seems like it would be useful for a variety of purposes, and cost about $5/day to run, if you only kept the last week or so of hashes and overwrote the stale ones.


texts: How do ethereum Dapps coins affect ethereum price?

texts: I mean, if, for example price of Akasha coins will rise, shoult it affect price of ethereum?


texts: How do we enable smart contracts on UTXO based chains?

texts:
Smart contracts fundamentally enable change of state programmatically. (Is that a fair  fundamental description?).

How would one go about enabling smart contracts on UTXO based blockchain as against an account model?


texts: How can we implement Proof of Stake on a private blockchain?

texts: I saw a lot of references to PoS but I cannot find any actual reference to implement it. Has someone the link which explains how to implement it on a private blockchain?


texts: May last block on watch only client become stale?

texts:
Let we have an ethereum node which is for a watch purposes only (it doesn't create any transactions, just updates it's replica of the whole chain).

To get notifications about top blocks in the chain in most of the Ethereum libraries (especially web3j and EthereumJ) we should write some listener class with some method which will eventually be called. Something like this:

class EthereumListener {
    public void onBlock(Block block) {
        long blockNumber = block.getNumber();
        //...
    }
}

My question is: may I be sure that the block which the listener is being notified is already on the main chain and will not become stale?

In other words: may the block be Uncle? May it be that if I later ask client for the block with this number I get a block with different content because Uncle block was replaced by the valid one in the client's replica?

If the answer is 'Yes' my second question is: does library (web3j or EthereumJ) notify me through the onBlock method about the new valid block when it replaces an Uncle one?

In other words: may blockNumber be the same between different invocations of onBlock method?


texts: What happens if I created a DAO smart contract and it loses alot of money. Can I get sued?

texts: In light of what has happened with theDAO and slock.it -- What will happen if I go public with my smart contract as a DAO and collected loads of money from people but then realize it became a loss. Can I as the DAO creator get sued even though a DAO is supposed to be self governing? Assume I'm from New York City. Or would the best course of action to take is to stay anonymous? But then no one would trust my DAO.


texts:
Let's say I have a uint public myvar in my contract that is initialized to some value.

Then, myvar gets set to 3 in the next block.

How can I retrieve the old value? Is this possible with web3?

Edit

Let's assume there are no Events that get emitted when myvar is changed.


texts: var is deprecated / var is used in solidity documentations / removing var is throwing compile errors

texts:
From Solidity tutorials:

contract C {
    uint[] counters;
    function getCounter(uint index)
        returns (uint counter, bool error) {
            if (index >= counters.length) return (0, true);
            else return (counters[index], false);
        }
    function checkCounter(uint index) {
        var (counter, error) = getCounter(index);
        if (error) { ... }
        else { ... }
    }
}

If I compile this with truffle, a warning is displayed:

  Warning: Use of the "var" keyword is deprecated.

What is ther alternate to removing var when receiving tupples from returning functions? I tried removing var but truffle refuses from compiling with error.


texts: Determining if a transfer to a contract is from another contract

texts:
I have two contracts, 0xA and 0xB, and they both have an attribute 'mate_address' which is the other contracts address. For instance, 0xA's mate_address is 0xB, and 0xB's mate_address is 0xA.

I want to define a function which can be called by any address, in this case 0xC, which will send the balance of one contract to another.

Here are the contracts:

0xA:

contract TheContract {
    address public mateAddress = OxB

    function () payable public {
        if (msg.sender == mateAddress) {
            //do something
        }
    }

    function checkStatus() {
        if (someCondition) {
            address myAddress = this;
            mateAddress.send(myAddress.balance);
        }
    }
}

0xB:

contract TheContract {
    address public mateAddress = OxA

    function () payable public {
        if (msg.sender == mateAddress) {
            //do something
        }
    }

    function checkStatus() {
        if (someCondition) {
            address myAddress = this;
            mateAddress.send(myAddress.balance);
        }
    }
}

When I try to call the checkStatus function, my transaction gets reversed at the if (msg.sender == mateAddress) line.

How could i get the behaviour that I want?


texts:
I'm trying to test out Ampleforth on Rinkbey using Remix. Here are all the files that I copy into remix.
https://github.com/cryptoghoulz/based-contracts/tree/master/contracts/v4
They compile fine, but when I deploy UFragments I get this error:

This contract may be abstract, not implement an abstract parent's
methods completely or not invoke an inherited contract's constructor
correctly.

Anyone know what could be going on? Thanks!


texts: Cannot connect to Infura inside a docker container: Cannot find module 'websocket'

texts:
When I put my script in a docker container, I can no longer connect to Infura:

Error: Cannot find module 'websocket'

in package.json

"web3": "^1.0.0-beta.34"

in my script:

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

myContract.events.Transfer({    // Transfer, allEvents, getPastEvents
    fromBlock: 0
}, function (error, event) {
    if (error) {
        console.log("error: " + error);
    } else {
        // console.log("event: " + JSON.stringify(event, null, 2));
        console.log("event: " + event);
    }
})

My Dockerfile is pretty standard.

Any idea of what my problem is ?


texts:
Let's say I have 5 contributors to a pool of a smart contract. They all contributed 1 ether. The smart contract lost 2 ether, and now I want to transfer back the remaining 3 ether to the 5 contributors but also refund the delta of the loss.

How can I mathematically define to refund the delta? do I need to use modulus?


texts: MyEtherWallet and transfer of Token (CLO) question

texts:
I cannot transfer my CLO to my new Ledger from MyEtherWallet. i get the not enough gas error even though i have .5 of ether on the same wallet. most likely i am missing something simple. can see the tokne (CLO) but in metamask it give me some crazy amount of 21 million ethereum instead of cLO when i go to send callisto.

Any help would be greatly appreciated.

Steve


texts: Lower level implementation of solidity call

texts: How is call() implemented at lower level in Ethereum Solidity compiler? Most of the places it is written that it is used to send message to contracts. But I need to know syntax and semantics of call() implementation at compiler level.


texts: Solidity: UnimplementedFeatureError: Only in-memory reference type can be stored

texts:
I am getting the follow error with the contract below when I compile in remix and javascript. Also how do I fix it.

  UnimplementedFeatureError: Only in-memory reference type can be
  stored.

pragma solidity ^0.4.0;

contract TwoupFactory {
    address[] public deployedTwoUpGames;

    function createTwoUpGame(uint minimum) public {
        address newTwoup = new Twoup(minimum, msg.sender);
        deployedTwoUpGames.push(newTwoup);
    }

    function getDeployedCampaigns() public view returns (address[]) {
        return deployedTwoUpGames;
    }
}

contract Twoup {
    struct Player {
        uint BetAmount;
        address Address;
        bool PickedHeads;
    }

    struct TossResult {
        bool HeadsCoinOne;
        bool HeadsCoinTwo;
    }

    TossResult[] public tosses;
    Player[] public players;
    address public spinner;
    uint public kitty;
    uint public totalBet;
    bool isGameCompleted;

    function Twoup(uint housekitty, address newSpinner) public payable
    {
        require(msg.value > 10 ether);
        spinner = newSpinner;
        kitty = housekitty;
        isGameCompleted = false;
        totalBet = 0;
    }

    function tossCoin() private view returns (bool) {
        return ((uint(keccak256(block.difficulty, now, players)) % 2) == 0);
    }

    function pickWinner() public
    {
        require(msg.sender == spinner);
        require(isGameCompleted == false);

        tosses.push(TossResult({ HeadsCoinOne: tossCoin(), HeadsCoinTwo: tossCoin() }));
    }
}


texts: Truffle Contract transaction doesn't wait to be mined

texts:
I have a thing that has been annoying me when using truffle-contract, ever since updating from Truffle 2 to Truffle 3.

I am no longer able to run transactions synchronously - even though it is stated on the Github page for truffle-contract that:

}).then(function(result) {
    // This code block will not be executed until truffle-contract has verified
    // the transaction has been processed and it is included in a mined block.
    // truffle-contract will error if the transaction hasn't been processed in 120 seconds.
    //
    // Since we're using promises, we can return a promise for a call that will
    // check account two's balance.
    return coin.balances.call(account_two);

When I run my client application:

https://pastebin.com/MbbL2bJt

It calls the createAccount function and then right after it calls the setBalance function, which causes the setBalance to fail since the account is not created before this happens.

This seems to me like it is the opposite of what the statement from truffle-contract says it will do.

If anyone can help, I'll be ever grateful

Simon


texts: What useful information can we get from ethOS mining log?

texts:
What useful information can we get from ethOS mining log information ?

For example, can we find the ethereum address of this miner from this log information ?


texts:
I am trying to execute the following example listed in the documentation using solidity 0.4

pragma solidity ^0.4.0;
contract C {
    uint[] data1;
    uint[] data2;

    function appendOne() {
        append(data1);
    }

    function appendTwo() {
        append(data2);
    }

    function append(uint[] storage d) {
        d.push(1);
    }
}

But I get the error:

  Error: Location has to be memory for publicly visible functions (remove the "storage" keyword).

When I remove the storage keyword I get another error:

  Error: Member "push" is not available in uint256[] memory outside of storage.
              d.push(1);

Any solution?


texts:
i want to get the token's transferring value like this:
https://etherscan.io/address/0x27054b13b1b798b345b591a4d22e6562d47ea75a#tokentxns

How can obtain the value of erc20 token in transaction?
https://etherscan.io/tx/0x4d2705650c17cec7703ea1d44c846fa41029b400c742bec2251c95e9bebfd037
Where and how can i get the value : "1,011.1323"

Thanks


texts: What is the best way to handle multiple NFTs of the same collection in ERC1155?

texts:
I'm learning ERC1155, and I'm a bit confused.
This is OpenZeppelin's example of an ERC1155 Contract:

They state that Thor's Hammer is an NFT (because only 1 was minted), while Gold is Fungible.
Therefore this example contains several Fungible Tokens:

Gold
Silver
Sword
Shield

And only one Non-Fungible Token:

Thor's Hammer

But what if I want my ERC1155 contract to have multiple Collections of Non-Fungible Tokens?
For example, say I want to create a Football Game with:

2 types of Fungible Tokens:

Gold
Silver

4 Collections of NFTs:

Players
Coaches
Jerseys
Stadiums

Example code:
//SPDX-License-Identifier: UNLICENSED
pragma solidity 0.7.0;

import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/solc-0.7/contracts/token/ERC1155/ERC1155.sol";

contract FootballGame is ERC1155 {

    address public admin;

    // Non-Fungibles
    uint8 public constant PLAYER = 1;
    uint8 public constant COACH = 2;
    uint8 public constant JERSEY = 3;
    uint8 public constant STADIUM = 4;

    // Fungibles
    uint8 public constant GOLD = 5;
    uint8 public constant SILVER = 6;

    constructor() ERC1155("https://example.json") {
        admin = msg.sender;
    }

    modifier onlyAdmin() {
        require(msg.sender == admin, "This operation is only for Admins");
        _;
    }

    function mintCoins(uint _coinId, uint _amount) onlyAdmin external {
        require(_coinId == GOLD || _coinId == SILVER, "Invalid Coin ID");
        _mint(msg.sender, _coinId, _amount, "");
    }

    function mintNFT(uint _tokenId) onlyAdmin external {
        require(_tokenId == PLAYER || _tokenId == COACH || _tokenId == JERSEY || _tokenId == STADIUM, "Invalid Token ID");
        _mint(msg.sender, _tokenId, 1, "");
    }
}

Is this right?
The constant variables are supposed to be IDs that represent each type of token, right? Or wrong?
For instance, if I want to create multiple Stadiums can I just mint multiple NFTs with the ID of the Stadium collection?
Or do I have to mint Stadium A with ID 22, Stadium B with ID 23, Stadium C with ID 24, and so on?
For NFTs in ERC1155, is an ID for each NFT? Or is it for each Collection of NFTs?


texts: Scenario and solution when multisend function fail

texts:
Assume that we have two MultiSend function, one for ether and another for ERC20/ERC223 token respectively.

My question is what would happen if one or more of the address fail. Will all the transaction be reverted and stuck forever? eg: One of the ether is transfer to address of smart contract that reject incoming ether transfer().

To simplify, i think that it will be a success transfer for an address but not the case for a contract address.

If it is the case, wouldn't that the MultiSend() function will not be succeed forever? And what is the solution to it. Or it just ignore the fail transaction only.

The full code can be view here

  function multiTransfer(address[] _addresses, uint[] _amounts)
    payable public returns(bool)
    {
        uint toReturn = msg.value;
        for (uint i = 0; i < _addresses.length; i++) {
            _safeTransfer(_addresses[i], _amounts[i]);
            toReturn = SafeMath.sub(toReturn, _amounts[i]);
            MultiTransfer(msg.sender, msg.value, _addresses[i], _amounts[i]);
        }
        _safeTransfer(msg.sender, toReturn);
        return true;
    }

 function multiERC20Transfer(
        ERC20 _token,
        address[] _addresses,
        uint[] _amounts
    ) public {
        for (uint i = 0; i < _addresses.length; i++) {
            _safeERC20Transfer(_token, _addresses[i], _amounts[i]);
            MultiERC20Transfer(
                msg.sender,
                msg.value,
                _addresses[i],
                _amounts[i],
                _token
            );
        }


texts: Several smart contracts for one coin - TAAS, Bancor?

texts:
tokens like TAAS or Bancor have their functionalities, but the are somehow splitted into several different smart contracts?

One of them:
https://etherscan.io/token/0x2e9e055d25530f7b3365e89c45bab1a1441159b4

I've the following question about Ethereum smart contracts:

Do I understand correctly that it is possible to "interlink" smart contracts?
In this case it means:
That the usual tradeable smart contract is just a "dumb coin" contract and all the functionality of the token is run on a seperate smart contract, like distribution of dividend?
How can they mask the smart contract so its not possible to see the code of the contract (see the link above).

Thank you greetings!


texts: How To Create a new Ethereum Account with Mist and Nano ledger S?

texts:
Intro:
In the past I managed to create 2 accounts that store the private keys in the nano ledger wallet S. I don't know how I did that.

Question:
I would like to create a new address account that stores the private key in my Nano ledger wallet. I would like doing that using just Mist/geth/nano ledger software.

thank you


texts: JSON RPC-HTTP API have any sort of rate limiting or throttling?

texts:
Is there any sort of rate limiting on the RPC-HTTP API? Trying to track down why my node (private chain) can only handle ~40 requests per/second. I am only load testing it with eth_blockNumber so they are quick calls. But after around 1200-1600 requests it starts to give ECONNREFUSED errors.

My go-ethereum node is hosted on an AWS EC2 instance (not behind a ELB), but for the load testing I'm testing directly with the instance's IP:port. I've tested a local node with the same load test and it passes fine, but not sure if this is a good 1-1 test since its just hitting localhost.

Wondering if its AWS rate limiting? But from what I have read they don't have that built-in, only if you use an Elastic Load Balancer. And I wouldn't think 40 requests per second would make it think it's a DDOS attack.

Any help is appreciated!