texts: How Do You Parse Web3 Retuned JSON Objects of Events?

texts:
I am using Web3 1.0 to listen to events from a contract like this:

tokenContract.events.AddressList({
        fromBlock: 6020474,
        toBlock: 'latest'
    },
    (error, events) => {
        console.log(events.returnValues[0])
     }
);

  I get back this:

      {

        transactionIndex: 12,
        id: 'log_0x18cb49c233bb0591f3b16eaa31c573a0171ce9d96390bd0639d741664d19f043',
        returnValues: {
          '0': '0xd204E0f9c07768D91eA2f27Dc01d48DC485e5046',
          '1': '0x6a57059920371e6819713c80a2c3E3E4fE21b7A6',
          '2': [BigNumber],
          src: '0xd204E0f9c07768D91eA2f27Dc01d48DC485e5046',
          guy: '0x6a57059920371e6819713c80a2c3E3E4fE21b7A6',
          wad: [BigNumber]
        },
        event: 'Approval',

      }
    ]
    [
      {

        transactionIndex: 13,
        id: 'log_0xff56909901d0d7f2981eb2b51383a5f284dc9ffa3626876cc5a62c84dedf821b',
        returnValues: {
          '0': '0xE59B0539f3eC6a8b70D60fEf5FcEDFB2C07516F4',
          '1': '0x6a57059920371e6819713c80a2c3E3E4fE21b7A6',
          '2': [BigNumber],
          src: '0xE59B0539f3eC6a8b70D60fEf5FcEDFB2C07516F4',
          guy: '0x6a57059920371e6819713c80a2c3E3E4fE21b7A6',
          wad: [BigNumber]
        },
        event: 'Approval',

        }
      }

  I want to push each returned events.returnValues[0] property (which is the field name '0:') to an
  array like this:

var addresses = []
    addresses = events.returnValues[0]
    addresses = objArray.map(events => a.returnValues)

//(Or maybe by iterating with a for loop somehow)

  Then I want to access the individual addresses with something like
  console.log(addresses[2])

Is there a better way to do this with Web3.js alone? All of the answers parsing JSON have not worked for me. I don't know where to begin.

Edit: It appears that Web3 returns not a JSON object containing all events, but individual objects. For example, Object.keys(AddressList).length returns:

1
1
1
1
1

  And console.log(events.returnValues['0']) returns:

0xd204E0f9c07768D91eA2f27Dc01d48DC485e5046
0xd204E0f9c07768D91eA2f27Dc01d48DC485e5046
0xd204E0f9c07768D91eA2f27Dc01d48DC485e5046
0xd204E0f9c07768D91eA2f27Dc01d48DC485e5046
0xE59B0539f3eC6a8b70D60fEf5FcEDFB2C07516F4

  The best I've got so far was this:

[ '0xd204E0f9c07768D91eA2f27Dc01d48DC485e5046' ]
[ '0xd204E0f9c07768D91eA2f27Dc01d48DC485e5046' ]
[ '0xd204E0f9c07768D91eA2f27Dc01d48DC485e5046' ]
[ '0xd204E0f9c07768D91eA2f27Dc01d48DC485e5046' ]
[ '0xE59B0539f3eC6a8b70D60fEf5FcEDFB2C07516F4' ]

  Which gets pushed only to the first entry of the array altogether. I want addresses[4] to return the address ending in 16F4, and addresses itself to return:

['0xd204E0f9c07768D91eA2f27Dc01d48DC485e5046', '0xd204E0f9c07768D91eA2f27Dc01d48DC485e5046', '0xd204E0f9c07768D91eA2f27Dc01d48DC485e5046', '0xd204E0f9c07768D91eA2f27Dc01d48DC485e5046', 0xE59B0539f3eC6a8b70D60fEf5FcEDFB2C07516F4]

  Edit two. The following code results in a wonky and unexpected return:

let myArr = []
tokenContract.events.AddressList({
        fromBlock: 6020474,
        toBlock: 'latest'
    },
    (error, events) => {
        myArr.push(events.returnValues['0'])
     }
);

[ '0xd204E0f9c07768D91eA2f27Dc01d48DC485e5046' ]
[
  '0xd204E0f9c07768D91eA2f27Dc01d48DC485e5046',
  '0xd204E0f9c07768D91eA2f27Dc01d48DC485e5046'
]
[
  '0xd204E0f9c07768D91eA2f27Dc01d48DC485e5046',
  '0xd204E0f9c07768D91eA2f27Dc01d48DC485e5046',
  '0xd204E0f9c07768D91eA2f27Dc01d48DC485e5046'
]
[
  '0xd204E0f9c07768D91eA2f27Dc01d48DC485e5046',
  '0xd204E0f9c07768D91eA2f27Dc01d48DC485e5046',
  '0xd204E0f9c07768D91eA2f27Dc01d48DC485e5046',
  '0xd204E0f9c07768D91eA2f27Dc01d48DC485e5046'
]
[
  '0xd204E0f9c07768D91eA2f27Dc01d48DC485e5046',
  '0xd204E0f9c07768D91eA2f27Dc01d48DC485e5046',
  '0xd204E0f9c07768D91eA2f27Dc01d48DC485e5046',
  '0xd204E0f9c07768D91eA2f27Dc01d48DC485e5046',
  '0xE59B0539f3eC6a8b70D60fEf5FcEDFB2C07516F4'
]


texts: How does the zero account transfer tokens?

texts:
In this transaction, the from address is withdrawing Dai from the Compound contract.

What puzzles me is why the zero address(0x00...) can transfer Dai to the from address.


texts: Making RPC calls without setting up my own node

texts:
My application is using web3 or Nethereum to connect to my own ethereum node (setup using geth).

Is it a must for me to setup my own node to make RPC calls (or connect to a specific node that setup by someone else)? If this is the case, when my node is down, my application is down as well. It is not as distributed as it should be.


texts: How to prevent having to `personal.unlockAccount()` all the time when using `geth` and `Remix`?

texts:
How to prevent having to personal.unlockAccount() all the time when using geth and Remix?

I'm using geth and Remix in combination to learn contract development.

All the time, I've to switch to the terminal and enter personal.unlockAccount() to use Remix.

Is there an option to unlock the account on a permanent basis when testing things?


texts: Collection of erc20 tokens from multiple addresses

texts:
I have main address: const fromAddress

There is also an array of addresses and their keys: foreth / keys

I need to send all tokens from the addresses of the foreth array to the main address fromAddress

Tokens are sent only from the first address of the foreth array, a hash is generated for all subsequent addresses, which is not on etherscan with error: Sorry, We are unable to locate this TxnHash

It is necessary to make sure that tokens are sent from all addresses that are in the array foreth

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

let tokenAddress = "";
let fromAddress = ''
let privateKey = Buffer.from('', 'hex')
let minABI = ABI_Token
let amount = web3.utils.toHex(3e18)

const contractInstance = new web3.eth.Contract(minABI, tokenAddress)
let foreth = ["addr1", "addr2", "addr3", "addr4"];
let keys = ['key_addr1', 'key_addr2', 'key_addr3', 'key_addr4']

function nonce_addr(address) {
    return web3.eth.getTransactionCount(address)
}

async function erc(){

for (var i = 0; i < foreth.length; i++) {
    const balance = await contractInstance.methods.balanceOf(foreth[i]).call(function(err, result) {
        let contract = new web3.eth.Contract(minABI, tokenAddress, {
            from: foreth[i]
        })

        if (result < 0) return
        web3.eth.getTransactionCount(fromAddress)
            .then((count) => {
                let rawTransaction = {
                    'from': fromAddress,
                    'gasPrice': web3.utils.toHex(20 * 1e9),
                    'gasLimit': web3.utils.toHex(71000),
                    'to': foreth[i],
                    'value': web3.utils.toHex(web3.utils.toWei("0.0008")),
                    'nonce': web3.utils.toHex(count + i)
                }
                let transaction = new Tx(rawTransaction)
                transaction.sign(privateKey)
                return new Promise((resolve, reject) => {
                    web3.eth.sendSignedTransaction('0x' + transaction.serialize().toString('hex'))
                        .on('transactionHash', console.log)
                        .on('receipt', resolve)
                        .on('error', reject)
                })
            }).then(receipt => {
                console.log("eth was send")
                for (var k = 0; k < keys.length; k++) {
                    let nonce =  web3.eth.getTransactionCount(foreth[i], 'pending');

                    let rawTransaction = {
                        'from': foreth[i],
                        'gasPrice': web3.utils.toHex(20 * 1e9),
                        'gasLimit': web3.utils.toHex(100000),
                        'to': tokenAddress,
                        'value': 0x0,
                        'data': contract.methods.transfer(fromAddress, web3.utils.toHex(result)).encodeABI(),
                        'nonce': web3.utils.toHex(nonce)
                    }
                    nonce++
                    let transaction = new Tx(rawTransaction)
                    transaction.sign(Buffer.from(keys[k], 'hex'))
                    let serializedTx = '0x' + transaction.serialize().toString('hex')
                    return new Promise(resolve => {
                        web3.eth.sendSignedTransaction(serializedTx)
                            .on('transactionHash', console.log)

                    })
                }

            })
    })

}
}


texts: Getting segmentation fault while compiling solidity contract

texts:
Getting segmentation fault when compiling a simple contract on geth on OSX Yosemite

web3.eth.getCompilers();
["Solidity"]
source = "contract test { function multiply(uint a) returns(uint d) { return a * 7; } }"
"contract test { function multiply(uint a) returns(uint d) { return a * 7; } }"
contract = eth.compile.solidity(source).test
solc: signal: segmentation fault

    at InvalidResponse (<anonymous>:-81662:-45)
    at send (<anonymous>:-156322:-45)
    at solidity (<anonymous>:-133322:-45)
    at <anonymous>:1:12

my geth version is 1.3.6 and solc is

  Version: 0.3.1-12797ed6/RelWithDebInfo-Darwin/appleclang/JIT linked to libethereum-1.2.3-3f84edc3/RelWithDebInfo-Darwin/appleclang/JIT

NOTE:
It also raises error when running solc on its own

19:49:55-makoto~/src/webthree-helpers (develop)$ cat contract.sol
contract test {
    function multiply(uint a) returns(uint d) {
        return a * 7;
    }
}
19:51:15-makoto~/src/webthree-helpers (develop)$ solc --bin -o solcoutput contract.sol
Segmentation fault: 11


texts: CompilerError: Stack too deep, try removing local variables

texts:
While trying to fetch more than 6 variables I am having an issue.
 /**
     *  Get data based on report id
     */
    function getData(uint256 id)
        public
        view
        returns (
            address,
            string memory,
            uint256[] memory,
            uint256[] memory,
            string memory,
            uint256 date,
            string memory
        )
    {
        return (
            data[id].owner,
            data[id].definition,
            data[id].support,
            data[id].likes,
            data[id].byteHash,
            data[id].date,
            data[id].text
        );
    }

How can I return more variables from a single get method without splitting them into two?


texts:
I am quite new with javascript web3 so don't be judge too hard.

I am using web3 version 1.0.0 beta.

I am taking the web3 reference this way:

if (typeof web3 !== 'undefined') {
    // If a web3 instance is already provided by Meta Mask.
    web3Provider = web3.currentProvider;
    web3 = new Web3(web3.currentProvider);
} else {
    // Specify default instance if no web3 instance provided
    web3Provider = new Web3.providers.HttpProvider('https://rinkeby.infura.io/v3/1b07b6c661304ef48005e16b43b7efa9');
    web3 = new Web3(web3Provider);
}

And then i am trying to get the contract reference:

var abi = [...];

console.log(abi);

var myContract = web3.eth.contract(abi, "0x2a2a7c53a6cc3d775e80c38d0fc446e73078902f");

myContract.methods.getPoll(1)
.call({from:localAccount}, function(error, result){
    console.log('error: ' + error);
    console.log(result);
})

The error is:  Cannot read property 'getPoll' of undefined


texts: Is uniswap supply and demand model opposite of other exchanges

texts:
Let's say we have an ETH/USD pair. Normally, I would expect that if more people are buying ETH than selling ETH, the price of the pair goes up. This is because there is more demand for ETH, but the supply (the people selling) is less, so they can charge more USD per ETH.
However, on uniswap, it appears to be the exact opposite. Due to the constant product formula, if more people are buying ETH, there is now excess ETH in the pool and a shortage of USD in the pool, and so the price of the pair goes down so that this can be rebalanced.
Am I right in what I am saying here, that Uniswap's supply and demand system is completely opposite to other exchanges? Does this mean that arbitrage between other exchanges is the only thing that's actually keeping the price right?
Does the constant product formula mean that the overall/average price of a pair remains constant? Does this mean the only thing that can actually change the overall/average price is by changing the constant in the constant product formula? And this is achieved from someone adding a different ratio of the assets to the liquidity pool?
Does this all mean that if no arbitrage occurred (hypothetically), the average price of every pair would remain constant?


texts:
I'm researching about smart contracts, and been seeing a lot of truffleframework, ganache and drizzle. In the other hand, only found broad descriptions of those tools:

"Drizzle is a collection of front-end libraries that make writing dapp front-ends easier and more predictable"

Still not sure of what is what in this framework, can anyone clarify that please?

Is Ganache a private/local blockchain?
Is Drizzle a browser to blockchain hook? Or something to work with solidity?
Is the Truffle a wrapper for those two?


texts: How to explain the process just before the smart contracts get executed, to a non-technical friend?

texts:
I would like to explain how the Ethereum smart contracts get initiated to run, and what they are, to a non-technical friend. I do not need to explain to them the execution of the contracts and the programming language that makes it programmable. I do not need to explain to them the P2P networking and decentralization. I simply need to explain the mechanism involved prior to executing a contract.

As analogy, think about it as explaining a vending machine. Inserting a coin into a vending machine is the transaction (me sending the money). Deciding whether it is the right coin (or the right amount) is the work the miners do. Selecting the product from a vending machine is the execution of the smart contract. What I need to explain to them is the part where the machine decides whether it is the right coin or the right amount of coins, just before executing the order I made.

A good answer that was already given is here:
At which point the smart contracts get executed?

However, what the answer lacks is explanation of the architecture and logistics.

Lets just say that I need something that can be put into an illustrated flow-chart, and that they will understand it when written in such a manner.


texts: How can i create the multisignature address using cli (Json rpc or web3)

texts: I need to integrate the multisignature wallet on my website. But the multisignature option only provided on the mist process so how i can integrate with site. I need the API


texts: Trying to compile a smart contract Error: Type literal_string

texts:
I'm learning smart contract, and I have a problem compiling one it gives me this error message:

  Error: Type literal_string "0x5c15741c7abb1b0e8fb0bd41b5ed8c17219926a1" is not implicitly convertible to expected type address.
      address multisig = "0x5c15741c7abb1b0e8fb0bd41b5ed8c17219926a1";

I have tried to me it looks like that, we shouldn't hard code the contract address?

here is the code of the line causing trouble :

address multisig = "0x5c15741c7abb1b0e8fb0bd41b5ed8c17219926a1";

thank you for your help!


texts: How do I handle the last step in getting more gas in The DAO withdraw process?

texts:
I've gone through he entire process here and am hung up on this last step; it says I don't have enough gas to execute the withdrawal. What do I do here?
step by step would be super helpful!! thanks!!

Here is the last step in the process I followed:

Execute The Withdrawal Contract Function

Withdraw ETH from the Withdrawal contract
In the Contract menu, select The DAO Withdrawal contract
Under the Write To Contract column on the right, select the Withdraw
function.
Under the Execute from field, select the account from which you want
to convert your DAOs into ETHs.
Click on Execute and enter your account password.
You should get a transaction confirmation message.
Wait a short while and your ether balance should update. If not,
restart Ethereum Wallet.


texts: geth inter-node communication (devp2p/rlpx) encryption

texts:
I am currently analysing the encryption mechanisms used in geth.

Currently I have gathered the following information from the source code (https://github.com/ethereum/go-ethereum/blob/master/p2p/rlpx.go):

communication is encrypted
no server certificate / CA chains like in TLS
Key Exchange via: ECDSA / secp256k1
ECDSA publicKeyLength: 256-bit
SharedSecretKeyLength: 16-byte

Is this correct so far?

Does someone know if there is any documentation on encryption in the inter-node protocol?

Update
From https://github.com/ethereum/devp2p/blob/master/rlpx.md (thanks Richard Horrocks for pointing to it):

  The RLPx handshake is considered 'broken crypto' because aes-secret and mac-secret are reused for both reading and writing. The two sides of a RLPx connection generate two CTR streams from the same key, nonce and IV. If an attacker knows one plaintext, they can decrypt unknown plaintexts of the reused keystream.

Update Asked at crypto.stackexchange.com about the encryption flaw above -> https://crypto.stackexchange.com/questions/63047/ethereum-rlpx-protocol-for-inter-node-communication-flaws-in-the-encryption


texts: Json RPC eth_sendTransaction data parameter

texts:
I have a question concerning the data parameter of the json RPC method eth_sendTransaction.
Is it possible to send any kind of data structure with this method to a smart contract?
Is it possible to store the data send with this method on the blockchain then, by storing it in a variable within the smart contract code?
I am asking because when we can send any external data to the client, why the need of oracle's?


texts: Wallets contracts not showing up in Wallet 0.8.6

texts: I guess since 0.8.2 wallet contracts havent showed up. How to see them in the Wallet once again?


texts: For loop syntax, iterating over an array

texts:
In this example:

  uint i;
    uint j;
    for(i=0;i<_baseBytes.length;i++) {
        _newValue[j++] = _baseBytes[i];
    }

  in the _newValue variable why is j++ been used. Surely _newValue[i] would suffice?


texts:
I saw a lot of questions over the internet on how to determine the number of token holders in solidity and  everybody says that its impossible to be determined without interacting with a solution that is stored off the blockchain.
I have an idea for this issue that got stuck in my head and I cannot see any downside except slightly higher gas required for each transaction.
The solution would be to define a unit property in the contract and initialize it in the constructor with the number of addresses that will hold balance at the end of the constructor logic execution. In the method that performs the transaction, write some logic that will increase the counter if the balance of the receiver is 0 and decrease the counter if the balance of the sender becomes 0 after the transaction.
  contract MyToken is ERC20{
    uint holders;
    constructor(string memory name, string memory symbol) ERC20 (name, symbol){
        holders = 0;
    }

    function transfer(address recipient, uint256 amount) public override returns (bool) {

        _transfer(_msgSender(), recipient, amount);
        if(balanceOf(recipient) - amount == 0) holders++;
        if(balanceOf(_msgSender()) == 0) holders--;

        return true;

    }
 }

Is there anything that I miss and will cause this solution to fail?


texts: How to store image data in smart contract in hexadecimal format?

texts: I am trying to store image data as hex in a smart contract. How can i do so. I am not able to find a way to convert image to hex in javascript. How can i do that as well?


texts: What is an example of an ICO or Crowdsale that used the Open Zeppelin RefundVault contract?

texts:
I am trying to understand the RefundVault.sol contract from Open Zeppelin for implementing a soft cap that would refund investors if the cap is not reached. I am struggling t wrap my head around it, particularly how the enum for State works and how the crowdsale can interact with the contract to effect the mapping for deposited.

I thought that seeing a working example of this implemented would help but I can't find any. Does anyone have any links to code that use either this, or some other method for a soft cap refund functionality?

Thanks for any help.


texts: Error: Invalid JSON RPC response: "" using infura

texts:
My code:

const contract = require('truffle-contract');
const fs = require('fs');
const HDWalletProvider = require('truffle-hdwallet-provider');
const Web3 = require('web3');

const fileContents = fs.readFileSync('../../build/contracts/CoincodeToken.json', 'utf8');
const coincodeArtifacts = JSON.parse(fileContents);
const coincode = contract(coincodeArtifacts);

const walletMnemonic = 'god wwe lawsuit tiny mobile door raccoon chaos foil someone city siege';
const walletAPIUrl = 'https://rinkeby.infura.io/Fwp5nmX6Ze5FouVcBlHs';

const provider = new HDWalletProvider(walletMnemonic, walletAPIUrl);

const web3 = new Web3(provider);
coincode.setProvider(new Web3.providers.HttpProvider("https://rinkeby.infura.io/Fwp5nmX6Ze5FouVcBlHr"));

web3.eth.getAccounts(function (err, ac) {
    if (err != null) {
        console.error("There was an error fetching accounts.");
        return;
    }
    if (ac.length == 0) {
        console.error("Couldn't get any accounts! Make sure ethereum client is configured correctly.");
        return;
    }
    var accounts = ac;
    var account = accounts[0];
    web3.eth.defaultAccount = account;
    console.log(web3.eth.defaultAccount);

    coincode.deployed().then(function (instance) {
        return instance.transfer('0xa977575a23c55aaa992cfa585c2efc15b404259b', 2000000000000000000000, {from:account}).then(function (value) {
            value = value / 1000000000000000000;
            console.log("Printing value: " + value);
        });
    }).catch(function (e) {
        console.error(e);
    });
});

Output:

0x24a60d3abe605a0ffc2852863eba5e517e5a4fc4

Error: Invalid JSON RPC response: ""
    at Object.InvalidResponse (/home/pravin-coincode/infura/node_modules/web3/lib/web3/errors.js:38:16)
    at XMLHttpRequest.request.onreadystatechange (/home/pravin-coincode/infura/node_modules/web3/lib/web3/httpprovider.js:125:24)
    at XMLHttpRequestEventTarget.dispatchEvent (/home/pravin-coincode/infura/node_modules/xhr2/lib/xhr2.js:64:18)
    at XMLHttpRequest._setReadyState (/home/pravin-coincode/infura/node_modules/xhr2/lib/xhr2.js:354:12)
    at XMLHttpRequest._onHttpResponseEnd (/home/pravin-coincode/infura/node_modules/xhr2/lib/xhr2.js:509:12)
    at IncomingMessage.<anonymous> (/home/pravin-coincode/infura/node_modules/xhr2/lib/xhr2.js:469:24)
    at IncomingMessage.emit (events.js:187:15)
    at endReadableNT (_stream_readable.js:1090:12)
    at process._tickCallback (internal/process/next_tick.js:63:19)


texts: What prevents the blockchain from being poisoned by copyrighted or illegal data?

texts:
It's possible to store data in smart contracts, and with the recent explosion of NFTs this is happening a lot. A couple of hundred kB is more than enough to encode copyrighted material - e.g. the text of a novel, a photo, or a short song.
My understanding is that every full node replicates the entire blockchain, including any stored data, and makes it available to its peers. So once a valid transaction including a copyrighted file has been added to the blockchain, every node will become a possessor and distributor of that file.
In many countries distributing copyrighted data without permission can lead to large statutory damages. I'm unaware of any law or doctrine that would protect or exempt blockchain use from ordinary copyright law. So potentially anyone running a full node could be on the hook for damages.
There's additional danger when considering data that carries criminal liability just for possessing it; for example privacy violations, child pornography, or classified information.
I can't find any real discussion of this issue. There's this question, but it was closed as a duplicate of three other questions, none of which address the issue. There's this question about illegal smart contracts, but that deals with who's liable for what a smart contract does rather than the liability that can arise just from storing and distributing it.
Is there a legal or technical fix for the issue of copyrighted or illegal material stored in the blockchain creating liability for node operators?


texts: Mist stuck not downloading last 100 blocks

texts:
My mist wallet won't download the final blocks it needs to be fully synced to the blockchain. I have 0.18 ether in my account which is visible on etherscan, but it won't show on Mist.

Is getting stuck on the final few blocks a known issue?  How do I get the final blocks and see my balance in mist?


texts: I have downloaded the latest Ethereum wallet and trying to run it. But the wallet is stuck with "Node Connection Error" message. I am working behind a proxy server. Is there anything I need to do about the proxy to get Ethereum wallet start?


texts:
I am using web3 with an infura enterprise account to store tx data into a mongodb. Ive noticed that I have many duplicate transactionhashes stored and just can not figure out why. Is this a known issue, or does anyone have an explanation for that? This is the code of the subscription.
    observe() {
    console.log(new Date() + ' start monitoring ' + this.wallets.length + ' addresses');
    let self = this;

    if (this.subscription === 'logs') {
        web3ws.eth
            .subscribe(this.subscription, (error, result) => {
                if (error) console.error(error);
            })
            .on('data', (data) => {
                setTimeout(async function() {
                    await self.checkTransaction(data);
                    self.requestCounter++;
                }, 2000);
            });
    }
}


texts:
i need your help.

I sent ETC from Coinbase to my ETH Wallet (Ledger Nano X).

The transaction: 0x1b007ab56371ecb70998d1a391d6ccf36cacf12c8a785140ffdb0d8a0c526148

How can i send my ETC from the ETH Wallet back to the ETC Wallet? I try with www.myetherwallet.com but i don`t found no way.

Or is it possible that an other person has a ETC Wallet with the same (as my) ETH Wallet id?

Thank you!


texts: debug_traceTransaction returns "insufficient balance to pay for gas"

texts:
At block 916647, tx hash 0xca879fcf2d0146fc4e214ed5d9747a2743b6a586b4f1de1541e52c2fe6be5bad

debug_traceTransaction returns error:

  $ curl -X POST --data '{"jsonrpc":"2.0","method":"debug_traceTransaction","params":["0xca879fcf2d0146fc4e214ed5d9747a2743b6a586b4f1de1541e52c2fe6be5bad",{"tracer": "callTracer"}],"id":1}'  -H "Content-Type:application/json" http://0.0.0.0:8545

  {"jsonrpc":"2.0","id":1,"error":{"code":-32000,"message":"tracing failed: insufficient balance to pay for gas"}}


texts: How to return string over 32 characters from bytes32[] array?

texts:
I have a bytes32[] array. I convert strings to bytes32 before they are added to the array as follows:

function stringToBytes32(string memory source) returns (bytes32 result) {
    assembly {
    result := mload(add(source, 32))
    }
}

which will turn the string into a hex like 0x5468697320697320612074657374206d65737361676520746861742077696c6c, for example.

However, if the string converted into bytes32 is over 32 characters, I don't know how to turn it back into its original string over 32 characters. Using web3.toAscii only brings back the first 32 characters.


texts: Should my application be decentralized? (Basic Question)

texts:
I know this is a seemingly basic question, but one that I have not found many solid answers to. I have been programming for a few years now and with the recent NFT boom, DApps have caught my interest. But is it worth going through the trouble to launch a decentralized app rather than doing it the traditional way? For example, I want a website that can simply have a couple typical diplay pages. But also has metamask implementation so I can display any NFTs I have purchased on my website. Would an idea like this need to build hosted on the ETH blockchain?
Overall, there has just been the looming question of, "Is a Dapp right for this particular website/project?"


texts: How to handle precision errors in solidity?

texts:
Say I have some division and the result is the answer is off-by-one.
I've multiplied it by 10^18 to give the decimals but the issue is its still off by one.
How do i stop repetitions of this calculation throwing it off by a considerable amount?
For example, if a user calls the function 10,000 times the answer is no longer off by one but has now deviated by 10,000.
What's the best way to handle this?
Is it ok to do this and hardcode the imprecision?
myVariable -= foo + 1


texts: "Error: invalid address" for dapp, works on geth (Ganache)

texts:
I have a contract that creates another contract in a function. I am testing the contract using Ganache. When calling this function using geth, it works fine. But when calling it using my dapp (yeoman, gulp, bower, etc.) it gives me "Error: invalid address" via the browser console.

I have copy and pasted the logic from my dapp into geth and it works as expected on geth, and the Ganache UI shows the transaction.

The following is the code:

web3 = new Web3(new Web3.providers.HttpProvider("HTTP://127.0.0.1:7545"));

web3.eth.defaultAccount = web3.eth.accounts[0];

var myContract = web3.eth.contract([abi left out for readability]);
var contractAddress = '0xae01c97dc970ad45f7be5d23ba72ae24640e90b1';
var contract = myContract.at(contractAddress);

function sendPurchaseTrade() {
    contract.makePurchaseTrade('0x427d25b7c0B71C1944df51765c55Bea1961e0a44', {value: 200000, gas: 3000000});
}

The respective HTML page has a button with onclick="sendPurchaseTrade();".

Non state changing calls to the contract work with the dapp.

Any ideas as to why the exact same code will work on geth but not in my dapp?


texts: Solidity: What is this syntax with an external un-implemented function?


texts: Within my truffle console I'm running web3.version.network and it's returning '1514147182983'. When I check the accounts under web3, it's still connected to testrpc. How do I transition this to my testnet (Rinkeby, Ropsten, etc) accounts?


texts: I'm looking into developing some Go software on Ethereum and I'm wondering - are there any API wrappers around for Ethereum (something like BTCSuite's BTCRPCClient is for Bitcoin)? I know there is a whole Go Ethereum implementation, but I'm looking for more lightweight way of interacting just with the JSON RPC server, rather than interacting with the whole network directly.


texts:
I keep getting an error: ethminer  Failed to submit hashrate :(
I am very new to this whole mining thing, and just want to learn more.
I am using:

Geth
Version: 1.5.0-unstable

ethminer version 1.2.7
Build: Linux/g++/Interpreter/RelWithDebInfo

This is the error:

miner  10:16:59.788|ethminer  Mining on PoWhash #d89fc0ca… : 2759410 H/s = 1572864 hashes / 0.57 s
  ✘  10:16:59.808|ethminer  Failed to submit hashrate.
  ✘  10:16:59.808|ethminer  Dynamic exception type: jsonrpc::JsonRpcException
std::exception::what: Exception -32700 : JSON_PARSE_ERROR: The JSON-Object is not JSON-Valid:  Database Error

I've used the commands (to start mining):

./build/bin/geth --rpc --rpccorsdomain localhost

./libethereum/ethminer/ethminer -G -F http://ethereumpool.co/?miner=10@[ADDRESS]@myrig

Btw I am guessing that [ADDRESS] is my coinbase (ethereum account on geth), is that right?

Any ideas why this is happening? I am currently using the develop branch from geth and Ubuntu Xenial


texts:
I am writing a smart contract. The smart contract always revert. How can I debug step by step my smart contract?
I am coming from javascript, so I was expecting a "console.log" or something like this.
I don't understand how to do it with remixIde...etc.
I don't understand how to debug my smartcontract. Any help?
Regards,
Stéphane


texts: Address has balance on both chains… What does this imply in my case?

texts:
I just saw http://gastracker.io/addr/0xD0A70CF1C09E5824F6B0833688D29aE43AB48d86

Does this imply I can send ᴇᴛʜ if I have only access to ᴇᴛᴄ balance ? I don’t control the private key of this address directly : I can use it, but not access it or view it.


texts: Problem of deploying contract with "testRPC" and "remix" : "creation of contract pending ..."

texts:
When I try to deploy a contract using testRPC and remix, I receive:

creation of contract pending ...

I tried even the default contract of http://remix.ethereum.org.

Steps: First I open cmd. Then I type testrpc. Then I select web3 Provider. And finally press the Deploy button.


texts: How do I compare the "scalability" capabilities between ethereum and bitcoin?

texts: I'm trying to assess how they can be compared.  Bitcoin can process 7 trans/sec, is there some equivalent on the Ethereum side?  How should I think about this and what quantitative info should I use?


texts: Getting error : This type of error is only supported in new experimental ABI Encoder while passing struct inside function

texts:
How can I pass struct to Function I tried doing it but all in vain

struct testSruct
{

    uint size;
}

function testFunc(  testSruct test) public returns(bool replaced)
{
    return true;
}

Getting error :

  This type of error is only supported in new experimental ABI Encoder


texts: Help - Token holder has more tokens than total supply

texts:
I found a token, where the total supply is 200000000000000 (200,000,000,000,000) and the decimals are 8 so the total supply should be 2M.

But now there is a token holder that generated tokens apperently out of the air.
The holder has more than 1,000,000,000,000,000,000,000,000,000,000 of the tokens.
Also the holder is the owner. But in the contract there is no function to increase the total supply. Instead, the holder has used the transfer function to hack some tokens.

He made a transaction with this transfer function (input data):

Function: transfer(address _to, uint256 _value)

MethodID: 0xa9059cbb
[0]:0000000000000000000000007dd2af6c0a7434df91dd663323b12cbc71b28be4
[1]:fffffffffffffffffffffffffffffffffffffffffffffffffbc7f99c5447fffe

the event says:

  Transfer 1,000,000,000,000,000,.... (a very long number) TOKEN NAME
  From FROM_ADDRESS to  TO_ADDRESS.

The token holder did only have 2000 of the tokens at that time, so there has to be a bug in the transfer function.

And the transfer function looks like this:
(I have added the comments as there are the things I do not understand):

function transfer(address _to, uint256 _value) returns (bool success) {
    require(balanceOf[msg.sender] >= _value);
    // The sender did not even have a small part of the amount he sent.
    // He had only about 2000
    // So, shouldn't the function stop here? Or does it not stop automaticly
    // with a require?
    // My thought here is, there is missing something like "return false".

    require(balanceOf[_to] + _value >= balanceOf[_to]);
    // Same than above

    balanceOf[msg.sender] -= _value;
    balanceOf[_to] += _value;
    Transfer(msg.sender, _to, _value);
    return true;
}

I am not experienced in solidity programming yet so I hope that someone can help me.
Can someone decode the input data and explain me what happened here?


texts: Metmask injection local client standalone

texts:
It is too confusing for me. I tried everything.

If I run the code in node.js with browserfy.. everything works fine.

No I want to run it on my webserver. As MetaMask states it will not inject the global web3 object any more. So I download the web3.js here and add it in the html file with:

Ok. Now I do:

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

     if (typeof Web3 !== 'undefined') {
        window.web3 = new Web3(window.web3.currentProvider);
        console.log('Found web3!');
        console.log('Your Account: '+ web3.eth.accounts[0]);
        startApp();
     } else {
        console.log("No web3!");
        getWeb3();
     }
});

But this gives me

  Cannot read property 'currentProvider' of undefined

Ok, I then tried:

    if (typeof Web3 !== 'undefined') {
        web3 = new Web3(web3.currentProvider);

returns:

  web3 is not defined

I also tried different thins like:

    if (typeof Web3 !== 'undefined') {
        var web3 = new Web3(window.web3.currentProvider);

Well, whatever I try I fail. Did I get the concept wrong?

How can I host a website and connect to the MetaMask provider?


texts: Must precompiled contracts be natively implemented?

texts:
Instead of just having special native code for each precompiled contract, a client could have special gas metering for those (as it is their main purpose) but keep the logic as EVM instructions.

Would this be possible?


texts: Is there a way to force uncle blocks generation in a testnet?

texts: In a local testnet, what could be done to force uncle blocks generation? I'm mining with multiple geth instances (different accounts) on a common CPU and very low difficulty genesis block.


texts: Passing constructor arguments from child contract to parent contract

texts:
The ERC721 standard contract requires a token name and symbol in its constructor. I have inheritance pattern that looks likes Contract A is B and Contract B is ERC721.

If I want to set my token name and symbol dynamically on deployment, do I have to raise the constructor argument through each stage (from A's constructor to B's constructor to ERC721's constructor) or can I raise directly from A to ERC721? If yes, how?

Currently I'm passing through each parent like so

pragma solidity 0.6.8;

import "@openzeppelin/contracts/token/ERC721/ERC721.sol";

contract B is ERC721 {

    constructor(string memory _name, string memory _symbol) ERC721(_name, _symbol) public {}
}

contract A is B {

    constructor(string memory _name, string memory _symbol) B(_name, _symbol) public {}
}


texts:
In my scenario, there are data sellers and data buyers which might be persons or organizations.

I would like to create a smart contract for data seller and another smart contract for data buyer where the smart contrast of buyer negotiate with the smart contract of several sellers to buy data automatically and without human innervation.

After that, payment and sharing data are carried out through off-chain or state channel.
I was wondering if you help me how can I do that.
regards,


texts:
Running a private POA with clique. I know it is possible to add and remove signers using clique.propose().

However, If I lose access to one of the sealers defined in the genesis file is it possible to disable it and add one to replace it?


texts: is it really helpful? how will it change the world?

texts: I have been interested in learning more about cryptocurrencies due to the fact that they are on the verge of changing our financial market. However, I want a definitive answer as to why cryptocurrencies are going to lead us into a new era? is it a good investment for the future?


texts: How to get the list of incoming (pending) transactions with web3?

texts:
I would like to verify if somebody send ETH to a particular address. How can I get the list of incoming (pending) transactions with web3 ?

I tried the example in the web3 documentation with subscribe(“pendingTransactions”):

http://web3js.readthedocs.io/en/1.0/web3-eth-subscribe.html#id7

var subscription = web3.eth.subscribe('pendingTransactions', function(error, result){
    if (!error)
        console.log(transaction);
})
.on("data", function(transaction){
});

But I get the following error:
TypeError: web3.eth.subscribe is not a function

Is there a way to get that list ?


texts: Price of gas from https://ethgasstation.info/

texts: The website https://ethgasstation.info/ contains a lot of information regarding the price of gas and this is confusing. My question is: what piece of information from the website should I use to determine the price of gas in my transaction?


texts: What is the ABI code of a map's getter function?

texts:
I'm currently trying to call Etherscan's API eth_call to check data from a smart contract. To do that, I need to pass the function ABI code and data. However, the data I need is stored in a map and I'm not sure what code that would map to.

The contract in question is here with the variable being

mapping (address => bool) public sendAllowed;

However, by doing

Keccack ("sendAllowed(address)") = 2f0c92d385bd4391c0edec32b0ac39252f8a9ecbcfb630748ddb154a80318288

I got the ABI code of 0x2f0c92d3. Plugging that into the Etherscan API, I didn't get the proper data though:

http://api-rinkeby.etherscan.io/api?module=proxy&action=eth_call&address=0xf455105e41f84e3f980d0908887a311233bb9953&data=0x2f0c92d3dc1f5d644e4016f3da89fe002f63fbeb8e071cf1&apikey=YOURAPIKEY

{
jsonrpc: "2.0",
id: 1,
result: "0x"
}

(should return true)

What is the correct ABI code to use for the public getter / how do I properly call the Etherscan API to get the data?


texts: Remix warnings - state mutability and public visibility

texts:
I  noticed the new Remix gave me two new warnings:

browser/Untitled.sol:6:5: Warning: No visibility specified. Defaulting to "public".
    function setFee(uint _fee){
    ^
Spanning multiple lines.

and

browser/Untitled.sol:15:3: Warning: Function state mutability can be restricted to pure
  function mul(uint256 a, uint256 b) internal constant returns (uint256) {
  ^
Spanning multiple lines.

Should I change anything?  Is it best practice to type out visibility?
Here's my simple code:

pragma solidity ^0.4.13;

contract test {

    uint public fee;
    function setFee(uint _fee){
      fee = Sf.mul(_fee,10);
    }

}

library Sf{

  function mul(uint256 a, uint256 b) internal constant returns (uint256) {
    uint256 c = a * b;
    assert(a == 0 || c / a == b);
    return c;
  }

}


texts: Getting ETHER balance from an account on Ganache node

texts:
Currently trying to get the amount of ether on a given account. Running Truffle on windows 10, and entered into the truffle console. Trying to run the following command:
web3.fromWei(web3.eth.getBalance(web3.eth.accounts[1],"ether").toNumber())

and getting the following errors:
...\node_modules\truffle\build\44.bundled.js:72466
    throw new Error(`Provided address ${address} is invalid, the capitalization checksum test failed, or it's an indirect IBAN address which can't be converted.`);
    ^

Uncaught:
Error: Provided address undefined is invalid, the capitalization checksum test failed, or it's an indirect IBAN address which can't be converted.

Not sure the issue here.


texts: Contract.new() promise is never resolved with truffle-contract

texts:
I encountered a problem with the following function:

public async createNoteWeb3() {
   let bank = await this.bank.at(this.bankAddress);
   try {
     let note = await this.note.new(this.bankAddress,{from: this.user.address});
     let status = await bank.addNote.sendTransaction(this.bankAddress,{from: this.user.address});
     let status2 = await bank.addNote.sendTransaction(this.bankAddress,{from: this.user.address});
     console.log('Status: ' + status);
   } catch (e) {
     console.log(e);
   }
   this.getNotesWeb3();
}

status2 is just for testing purposes. Normally the first status should take note.address as parameter instead of this.bankAddress.

However when commenting out the "let note" line or rejecting the first metamask request for the contract creation the following two transactions pop up nicely one after another or the "catch" part shows up. But when I accept the contract creation no follow up transaction shows up. There is also no error in the log.

Any advise how to handle this?

(truffle-contract on the truffle dev chain with metamask in chrome)

update:
It looks like that the promise is never resolved if the new() function is successful. If I reject the contract creation the code jumps into the "catch" part.


texts:
Imagine that we have developed a couple of smart contracts and we deploy in a production enviroment. With the pass of the time we look that we need some functions that in the deployed contracts are not.

So beeing imposible to update the deployed contract. What are the best practices to solve this cain of common mistakes without lose the data?

In the new contract call to the old contract functions to recover the data and works with bouth
...
..
.

Is a conceptual doubt the scenario is not reall. But I think in if I face with it


texts:
I am working on the frontend where I use try / catch to find errors and give appropriate messages to users. My smart contract has a payable function and I was at the point of catching errors regarding gas usage.

uint[] public theArray;

function myFunction(uint bigNumber) payable public {
         if(msg.value == 0.01 ether){
         theArray.push(bigNumber);}
else {if (msg.value == .05 ether){
            for (int i; i<50;i++)
            theArray.push(bigNumber);

        }
else {
    revert();
}
}}

Now when I try to catch the errors, the same error can have two different 'outputs' (err.message). The examples:

Using MetaMask on Rinkeby testing network

If I send 0.05 ETH with 21,000 gas or even 21,001 (minimum amount) the error I am getting is:

  Returned error: Error: Error: [ethjs-rpc] rpc error with payload

However if I send 0.05 ETH with 25,000 gas (not enough gas so it still fails) the error I am getting is:

  Transaction has been reverted by the EVM

Could anyone explain me why if I increase the gas amount the error changes?

Another thing I noticed is that if I send an invalid amount such as 0.04 I am also getting

  Transaction has been reverted by the EVM


texts: adding the contract value but still not changed

texts:
I am using web3 1.0 and testrpc, The following is my contract.

pragma solidity ^0.4.18;
contract LocalEthereum {

    event Created(bytes32 _tradeHash);
    uint32 value = 0;

    function addValue()  external {

        value = value + 1;
        Created(0x01);
    }

    function getValue()  returns (uint)  {

        return value;
    }
}

This is the js application.

   createValue(account){
      console.log('createEscrow');
      this.escrowContract.methods.addValue().send({from: account,gas:210000,gasPrice:5000000000})
                      .on('transactionHash', function(hash){
                          console.log('hash',hash);
                      })
                      .on('receipt', function(receipt){
                          console.log('receipt',receipt);
                      })
                      .on('confirmation', function(confirmationNumber, receipt){
                          console.log('confirmation',confirmationNumber);
                      })
                      .on('error', console.error);

  }

  this.escrowContract.methods.getValue().call({from: account})
                    .then(function(result){
                        console.log('getTestValue',result);
                    });

I have used createValue() multiple times, so the expected results is the value variable in the contract will be non-zero, however when calling the getValue() method, it is still zero value.

what is the problem?

---------------------------------------------------------------

it is wield that I changed the value to 10 instead of 0, but the method still return 0.

this.escrowContract.methods.getValue().call({from: account})
                    .then(function(result){
                        console.log('getTestValue',result);
                    });

this is the testrpc console output of transcation and call method,

eth_sendRawTransaction

  Transaction: 0x0f22da3b8ee8bc286afab370dc0b38734e4c51eda2eb6d81176de8ac0a980fd8
  Gas usage: 21272
  Block Number: 8
  Block Time: Tue Jan 02 2018 12:26:22 GMT+0000 (GMT)

eth_getTransactionReceipt
eth_call

everything seems to be normal.


texts: Drizzle Contract call returns unexpected object

texts:
I have a view function in my smart contract that returns a uint.

In the Truffle Drizzle javascript page I make the call when the page loads:

this.contracts.TheContract.methods.getNumber.call()

I would have expected a Big Number Object.
instead:

arguments:[]
call: ƒ ()
encodeABI: ƒ ()
estimateGas:ƒ ()
send: ƒ ()
_ethAccounts:
Accounts {_requestManager: RequestManager, givenProvider: MetamaskInpageProvider, providers: {…}, _provider: MetamaskInpageProvider, …}
_method:
{constant: true, inputs: Array(0), name: "getNumber", outputs: Array(1), payable: false, …}
_parent:
Contract {_requestManager: RequestManager, givenProvider: MetamaskInpageProvider, providers: {…}, _provider: MetamaskInpageProvider, …}
__proto__:Object

If I make a call on that object it returns a promise; not what I was expecting for a standard call.

cacheCall returns 0x0; an empty address? huh?
Has anyone  been able to use truffle and drizzle without having to fallback to standard web3?

ideas?

Thanks


texts:
this.call(bytes4(keccak256("setGBA(uint32)")), 12);

How to call function by string name? I can't modify store in function. How to do this?


texts:
Why doesnt Ethereum support concurrency?

https://en.m.wikipedia.org/wiki/Concurrency_(computer_science)


texts: pushing into struct array at a particular index

texts:
Question 1:
What i am trying to make is an array of struct "someStruct" which will be "someStructs".
Now i am setting some values in the struct array at index "_prop1" in  "createSomeStruct()".
Now if i want to set further values of the struct at the same index "_prop1", which i am trying to do in addUsers function.
How will i do that?

Question 2:
Is it possible to have a mapping inside the struct, if yes how can we do that, if you could direct me to some documentation or example for that.

pragma solidity ^0.4.10;

contract A {

    struct someStruct{
        uint prop1;
        uint prop2;
        address [] users;
    }

    mapping (uint => someStruct) public structList;
    someStruct[] public someStructs;

    function createSomeStruct(uint _prop1, uint _prop2){
        structList[_prop1].prop1 = _prop1;
        structList[_prop1].prop2 = _prop2;
        someStructs.push(structList[_prop1]);
    }

    function addUsers(uint _prop1, address _userAddress){
        structList[_prop1].users.push(_userAddress);
        //....?

    }
}


texts: How to create a website that runs on blockchain

texts:
A premise, I have confused ideas about smart contract client.

I would like to create a website, that runs a classic browser, with a javascript file imported that can execute functions on the blockchain.

I've seen Web3JS but it seems to be a NodeJS library (in fact it use the require() function that is not a built-in function in a Javascript console). I'm searching for a way to connect to the remote node and then execute the smart contract on it and then read the output. But, if a user that uses my website has a local node running, then I use its node instead of my remote node.

Can anyone help me to understand which components I need and how to orchestrate all the components?

I don't know, help me to understand, if instead of connecting to remote node, is it possible to start a light-client on a client browser in a few second?


texts:
I have a smart contract that emits an event called Transfer
emit Transfer(from, to, value);
I want to know the values of from, to, and value of each transaction (by providing a transaction hash or something). How can I achieve this by ethers.js library (Currently, I'm on ethers 5.0)


texts:
I run ganache, truffle and metmask. If I run the code below I get an error on the this.web3.eth.sendSignedTransaction() function:

EDIT: changed my code to the following.. Error remained the same though.

    const encoded_tx = this.contract.methods.createCountry("NL", 100, 100, 100000000, this.account).encodeABI();
    const nonce = await this.web3.eth.getBlockTransactionCount(this.account);
    const rawTx = {
        nonce: this.utils.toHex(nonce),
        gasLimit: this.utils.toHex(3000000),
        gasPrice: this.utils.toHex(this.utils.toWei('20', 'gwei')),
        data: encoded_tx,
        from: this.account,
        to: this.contractAddress
    };

    let tx = new Tx(rawTx);
    tx.sign(this.pvtKey);

    let serializedTx = tx.serialize();
    this.web3.eth.sendSignedTransaction('0x' + serializedTx.toString('hex'))
    .on('receipt', console.log);

The error is the following:

index.js:2178 Error: Returned error: {"id":6,"jsonrpc":"2.0","error":{"code":-32603}}
at Object.ErrorResponse (errors.js:29)

I have absolutely no idea where to look anymore and feel like I've tried everything, might it have anything to do with the fact that I'm connected to metamask?  When I try to send this transaction through metamask with eth.method.send() the transaction does not give an error and behaves as expected.


texts: Downloading a specific version of solc within a Docker image

texts: I am working with the release of Solidity v0.4.25 for it works well with py-solc. When running on a local machine the codebase works quite well with 0.4.25. My issue currently is to get the codebase running on a Docker image with Ubuntu. I initially tried installing the Ubuntu PPA but the release that is currently out does not work with my code. Anyone know how to get 0.4.25 installed via the Dockerfile? (first time I have ever asked a question on exchange so quite desperate here).


texts: Can you call a contract function via a cron job?

texts: I'm trying to automate the calling of a contract function. Every day, I would like to call a function in one of my contract that makes data available to the users of my DApp. I would like to automate this so that I don't have to manually call the function my self. Is it possible to automate this process on a webserver with a cron job? If not is there a better way to do this (preferably without having to run a vps)


texts:
I get Test1 from Test2.map, before I use Test1 function, how can I check null of Test1?

Code:

contract Test1 {
    function someFunc() public {}
}

contract Test2 {
    mapping(uint => Test1) map;
}


texts: Sending contract transaction to non-contract address

texts:
What happens if one sends contract transactions to non-contract address (Geth account)? E.g. one writes the transaction to call contract function, but the destination address is geth account?

There kind of transactions doesn't seem to cause out of gas. The transaction goes silently through. However is there a way to detect such a condition?


texts: How can i retrieve the values matching to an id in solidity

texts:
pragma solidity ^0.4.23;

contract tracking  {

  struct  data  {
    uint   ownernumber;
    uint   id;
  }

  uint value;
  mapping (uint256 => data) public  datamatching;

  function storedata (uint _ownernumber, uint _id) public {

    var  persondata  = datamatching[value];
    persondata .ownernumber = _ownernumber;
    persondata. id  =  _id;

  }

  function getData(uint256 userId) returns (uint){

   }
}

1) I wrote a function to store the values in my solidity code

2) Now in getData function, I want the user to enter the ownernumber and get all the details  matching to the ownernumber is it possible please help me

  Common errors:

  Use of the "var" keyword is disallowed.  Data location must be

  "storage" or "memory" for variable, but none was given


texts: I don't understand. What is the point of transaction fees if new ETH is generated as a mining reward?


texts: What is Whisper and what is it used for?

texts:
It's admittedly a very general question, but I've heard "Whisper" mentioned in several places when reading about certain DApps.

I understand it allows peer-to-peer messaging of some kind, but what are the purposes of these messages, and who is it that they're passing between? Is it a way for DApps or contracts to communicate, or something else?


texts:
Can I broadcast someone else signed transaction and use fee from my address? if yes then how?
Let me elaborate my Question Suppose person A want to transfer some ERC tokens to person B. But person A got zero ether in his account. so person A will sign the transaction and give it to person C and person C will broadcast the transaction. So in this case which account fee will deduct from person A's or from person C's.
if it will try to take from person A i want something like it will take fee from person C's account.
Thank you!!


texts:
n00b question here but when do I need my Wallet password? From what I understand you can just copy your Mist-files from one computer to another and without re-entering the password access your wallet.

Do you need the password to sign transactions or something?


texts: Transaction not showing on Kovan etherscan even after its status showed transaction mined and executed successfully

texts:
I have my contract deployed on Kovan Testnet and from remix IDE I called one of the functions of my smart contract through remix itself. Now, the status of transaction shows "transaction mined and executed successfully" and I'm also able to retrieve the transaction hash but when I view it on Etherscan.io it shows me "Sorry we are unable to locate this TxnHash."
Please help me out as I'm also using this Smart contract in my final year project.


texts: Does nodes have maximum limit of transactions

texts: Does geth/parity nodes have a maximum limit of transactions that they  can have (in queue) after which they stop accepting transactions (or apply back pressure or something)


texts: I tried to buy token with DAI. Its approved but I didnt receive any coin. Help please

texts:
It says that:
Transaction Action:
ApprovedDAIFor Trade OnUniswap V2: Router 2
Here is the transaction on etherscan: 0x181630a7d1ffaa58588eb6c5500d7f8529ca477621559eaf4a7587729e7ad45a
Why It didnt swap the coins but take the gas fee?
I didnt understand what is approved then?


texts: If I have one signer node designated on my genesis block and start it up, can I have an unlimited number of regular nodes? Will the signer node sign for all of them, or does the network have to have a ratio of signer/regular nodes?


texts: how is the type casting happening in the below example

texts:
while reading the ethereum docs about contracts came across the example mentioned here. In the ownedcontract constructor there is a casting at statement#2

creator = TokenCreator(msg.sender);

where msg.sender is of type address.

At first glance, I thought it's a constructor call but in the explanation it is clearly mentioned that it is a type cast.

How is it a cast? what is happening in the above statement?

To access a contract we need the address of the deployed contract
right?
How is the contract available in the first place?
Will the contract be still available if they both are deployed
    seperately i.e, one after another?


texts: How to use web3j to check the balance of an ERC20 custom Token and transfer the token to another wallet?

texts:
I'm studying to create wallets using infura, web3j, and android studio.

I am using ropsten testnet.
I have been able to check the amount of ethereum in my wallet and send ethereum to another account.

But I do not know how to check the balance of the custom token I issued and how to transfer it to another account.


texts: Problems requesting data to Open Ethereum (ex parity) node

texts:
I am creating an open ethereum (ex parity) node through the command:
./openethereum --mode active --db-compaction ssd --base-path="/media/nodessd/data" --cache-size 1024

When I try accessing the node through web3 in localhost: http://localhost:8545, I can interact with the node fine.
If I remotely try accessing the node through web3 by using as url: http://:8545, web3 returns the error: Invalid JSON RPC response: ""
How can I solve the issue? Thanks


texts: Dapp working in metamask but not in mist!

texts:
I made a dapp using meteor. I deployed a smart contract in ropsten with remix. My dapp works fine working with metamask without running a geth node.Now if I open same application in Mist browser instead of chrome, no functionality works, and console gives following error-

I started geth, with --ipc and opened connected my mist using geth only like said at this- http://remix.readthedocs.io/en/latest/tutorial_mist.html

It gives same error?? Geth necessary or not? Any help appreciated please.
Keep in mind that I have to work so as to deploy it very soon. I have put my web3 address at 8545 even working without geth metamask works fine??curious about that.


texts: I am deploying a Smart Contract to a private blockchain. Is it possible to get when your node receives the smart contract? Is it possible to identify the block which contains the smart contract? how?


texts: Can jsonRpcProvider.getSigner() take any address as an argument?

texts:
I am using the ethersjs when I connect to web3.
And I have a question about the getSigner() method below.
https://docs.ethers.io/v5/api/providers/jsonrpc-provider/#JsonRpcProvider-getSigner
Does this mean that if I pass someone else's ethereum address as an argument, I can create an object that will be signed by that address?
for example:
const provider = new ethers.providers.JsonRpcProvider('https://mainnet.infura.io/v3/{INFURA_API}')
const signer = provider.getSigner(SOME_RANDOM_ETH_ADDRESS)
const instance = new ethers.Contract(contractAddress, abi, signer)
const tx = await instance.transfer(MALICIOUS_ADDRESS, 10000000000000000)

My impression is that this could be a security issue, but why is this safe?


texts: Has someone an example string to connect using parity?

texts:
I have a geth connection as follows -

  geth --datadir ~/blockchain/mybc1 --rpc --rpcaddr "localhost"
  --rpcport 8545 --unlock "0x0c12901e1ec7f80763cd433e8eca0c837d11a0c1" --rpc --networkid 1234 --rpccorsdomain "*" --rpcapi "eth,net,web3" console 2> consolemybc1.log

I read the docs for parity but I could not find a clear example and there are a lot of options with parity.

How would I convert this into connecting with the parity client aside from changing geth to parity?


texts: Using Web3 to pull block #, hash, and timestamp

texts:
Can anyone give me advice on using web3 to pull the latest block number, hash and timestamp using Web3? I can't get this to work, and the documentation is fairly weak from what I've seen. Once I pull the values I am going to load them into p elements in my web page, so that's why I have the getElementByID statements. script and HTML code below

//connect web3 and check if web3 is connected correctly
    if (typeof web3 !== 'undefined') {
        web3 = new Web3(web3.currentProvider);
    } else {
        // set the provider you want from Web3.providers
        web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
    }
    if(web3.isConnected()) {
    console.log("connected");
    } else {
    console.log("not connected")
    }

//pulls state information from the blockchain
    web3.eth.filter('latest').changed(function(){
      var blockNumber = web3.eth.number;
      document.getElementById('latestBlock').innerText = blockNumber;
      var hash = web3.eth.getBlockNumber();
      document.getElementById('latestBlockHash').innerText = hash;
      var timeStamp = web3.eth.block(blockNumber).timestamp;
      document.getElementById('latestBlockTimestamp').innerText = Date(timeStamp);
    });

Blockchain Monitor

Ethereum Network

Coinbase Address:

Latest Block Number:

Latest Block Timestamp:

Latest Block Hash:


texts: Solidity: How could I apply delete to complete storage ref[] with one call?

texts:
Definition:

 mapping(address => data)         clusterContract;

 struct data { //defined inside a Library.
    mapping(address => Library.Struct[]) my_status;
 }
 data list;
 clusterContract[id] = list;

Usage:

clusterContract[msg.sender].my_status[id].push( Library.Struct({ status: status_ }));
delete clusterContract[msg.sender].my_status; //<=error occurs.

Error occurs:

Error: Unary operator delete cannot be applied to type
mapping(address => struct ReceiptLib.Status storage ref[] storage ref)
    E               delete clusterContract[msg.sender].my_status;

On the other hand: delete clusterContract[msg.sender].my_status[id] works.

=> Does delete clusterContract[msg.sender] removes(initialise to 0) complete array of my_status as well?

[Q] How could I apply delete to complete storage ref[]? or do I required to iterate ref[](keep track of the ids) and apply delete one by one as shown on the example?

Example:

for(int i=0;i<storedIDs.size();i++)
   delete clusterContract[msg.sender].my_status[storedIDs[i]];

Thank you for your valuable time and help.


texts: Are there any other mining clients than Ethminer?

texts:
I mine with ethminer on dwarfpool.

I use this version: 0.9.41-genoil-1.0.7 Beta for Windows. I would like to try another client if its possible. Is there another client than ethminer? I would like to try another one because he crashed a a lot.

Thank you!


texts: Smart Contract is being deployed but call does not return contract address after deployment

texts:
So I have been trying to deploy a smart contract using nodejs, but when I call the function to deploy, I get no contract address on my console. It's like the send() function never completed its execution. And that's why the next instruction never starts its execution, even though I know that the contract is still being deployed on my local blockchain network (I know it because I can see on the cmd prompt where my ganache-cli is running.
I'm trying to get the deployed contract address, please tell me how to do the same.
Expected behavior
Calling await contract.deploy({..}).send({..}) should return response, and after that contract address should be printed on the console.
Actual behavior
Instead, no output is printed on the console after this: 'Deploy function called, about to deploy'.
command prompt output stops after:

D:/User/project>node src/deploy
No web3? You should consider trying MetaMask!
[AsyncFunction: deploy] entered, about to deploy

Although, I know that the contract has been deployed because my ganache-cli shows this output:

Transaction: 0x12345
Contract created: 0x12345
Gas usage: 1605526
Block Number: 6
Block Time: Date and time of deployment is shown

Here is the code that I'm trying  to run: (deploy.js)
var Web3 = require('web3');

// abibytecode[0] has abi, abibytecode[1] has bytecode
const abibytecode = require('../src/compile');
var web3;

if (typeof web3 !== 'undefined') {
    web3 = new Web3(web3.currentProvider);
} else {
    // set the provider you want from Web3.providers
    console.log('No web3? You should consider trying MetaMask!');
    web3 = new Web3('ws://localhost:8545');
}

let account = 'my account address is here';

const contract = new web3.eth.Contract(abibytecode[0]);

const deploy = async () => {
    console.log('Deploy function called, about to deploy');
    const response = await contract.deploy({data: abibytecode[1]}).send({
      from: account,
      gas: '3000000'
    });
    console.log('Contract deployed to:', response.address);
    console.log('Contract deployed to:', response.options.address);

    return response;
};
console.log(deploy);
deploy((res)=>{console.log(res)});

Versions:

web3.js: 1.0.0-beta.55

nodejs: v10.16.0

browser: None, running the script from command

ethereum node: ganache-cli

Also, this is my first ever post on stackexchange, so if I've missed out some information let me know and I'll fill the voids.


texts: Invalid JSON RPC response on IOS build with Infura

texts:
I am developing a mobile DAPP using ionic frame work, everything was fine when I testing on the browser. However I try to build my app on IOS, and run it on my Iphone7, the web3 doesn't work(did't have any action within the app), then I try to debug with the ionic dev app, and it show up an error with Invalid JSON RPC response. And I try to build as android app, and everything works. My ERC20 token contract was deployed on the Ropsten network.

My app information:

ionic 3.9.2

web3 1.0.0-beta.36

ethereumjs-tx 1.3.7

ethereumjs-util 6.0.0

provider: 'https://ropsten.infura.io/v3/myapikey',

import Web3 from 'web3';
this.web3js = new Web3(new Web3.providers.HttpProvider(provider));
this.tokenContract = new this.web3js.eth.Contract(abi,contractAddress);
this.tokenContract.methods.balanceOf(myAddress).call().then(balance=>{console.log(balance);});

Does anyone face the same issue before?

Thank in advance.


texts: Was testing this code I found online but keep getting errors?

texts:
pragma solidity ^0.5.0;

contract Courses {

struct Instructor {
    uint age;
    string fName;
    string lName;
}

mapping (address => Instructor) instructors;
address[] public instructorAccts;

function setInstructor(address _address, uint _age, string memory _fName, string memory _lName) public {
    var instructor = instructors[_address];

    instructor.age = _age;
    instructor.fName = _fName;
    instructor.lName = _lName;

    instructorAccts.push(_address) -1;
}

function getInstructors() public view returns ( address[]) {
    return instructorAccts;
}
}

I keep getting errors saying the var keyword is disabled and data location must be memory for return parameter in function, but none was given.


texts: MetaMask - lost connection when page is loaded on browser launch

texts:
When launching a Chrome/Firefox Tab ethereum.send is never resolved.
The following warnings occur:
contentscript.js:1 MetamaskContentscript - lost connection to MetaMask Background Multiplex
s @ contentscript.js:1
contentscript.js:1 MetamaskContentscript - lost connection to MetaMask muxed traffic for channel "provider" failed.
s @ contentscript.js:1
contentscript.js:1 MetamaskContentscript - lost connection to MetaMask muxed traffic for channel "publicConfig" failed.

This question refers to This Issue on Github


texts: Token addresses for DAI , USDC and WBTC for IUniswapV2Router02

texts:
I have searched a lot but maybe I am looking in the wrong places.
Please how can I get the token addresses for USDC , WBTC and DAI that work with Uniswap Router02 on mainnet and kovan.
Thanks


texts: Remix (browser solidity) won't deploy my contract (through metamask)

texts:
I'm trying to deploy a new contract for testing on the ropsten network. I'm using remix and metamask, but for some reason I can't select injected Web3 (what used to be the standard setting) and thus it can't deploy.

Anyone who can help?

Code is:

pragma solidity ^0.4.11;

contract ZorgPolisBasic {

address public patient;
address public huisarts;
address public specialist;
address public verzekeraar;
bool public verzekeraaraanvullenbasis;
bool public verzekeraaraanvullenspecialist;
bool public huisartsuitgevoerd;
bool public specialistuitgevoerd;
bool public doorverwijzen;
uint256 public huisartsentarief = 1 ether;
uint256 public specialistentarief = 2 ether;
string public akkoordgeven;
string public fraude;
string public artsendecla;

//alle parameters op 0
function ZorgPolisBasic(){
patient = msg.sender;
huisarts = 0x33E225e01bba3AA05ADDCD8F38142a8d47F9dC37;
specialist = 0xAB7fAE73effD38B5EdaD696E1fb062b0F6863459;
verzekeraar = 0xa8323F5fBcf1980B2093a633cF03020900B81d53;
verzekeraaraanvullenbasis = true;
fraude = "none";
}

//hier claimt de huisarts zijn consult
function huisartsclaim(){
huisartsuitgevoerd = true;
doorverwijzen = false;
akkoordgeven = "bevestig behandeling huisarts";
}

//hier verwijst huisarts door en claimt tegelijk zijn consult
function huisartsdoorverwijzing(){
huisartsuitgevoerd = true;
doorverwijzen = true;
verzekeraaraanvullenspecialist = true;
akkoordgeven = "bevestig behandeling huisarts";
}

//deze twee bevestigen danwel ontkennen de behandeling huisarts
function patientbevestigdHA (){
if (huisartsuitgevoerd==true){
    huisarts.transfer(huisartsentarief);
    verzekeraaraanvullenbasis = true;
    huisartsuitgevoerd = false;
    akkoordgeven = "";
    artsendecla = "";
}else{
artsendecla = "Huisarts heeft nog niet geclaimd";
}
}

function patientontkentHA (){
if (huisartsuitgevoerd==true){
fraude = "patient ontkent behandeling huisarts";
huisartsuitgevoerd = false;
doorverwijzen = false;
akkoordgeven = "";
}else{
}
}

//hier claimt de specialist
function specialistclaim(){
if (doorverwijzen==false){
    fraude = "specialist claimt zonder doorverwijzing";
        }else{
    specialistuitgevoerd = true;
    akkoordgeven = "bevestig behandeling specialist";
}
}

//deze twee bevestigen danwel ontkennen de behandeling specialist
function patientbevestigdS (){
if (specialistuitgevoerd==true){
    specialist.transfer(specialistentarief);
    specialistuitgevoerd = false;
    akkoordgeven = "";
    artsendecla = "";
}else{
artsendecla = "Specialist heeft nog niet geclaimd";
}
}

function patientontkentS() {
if (specialistuitgevoerd==true){
fraude = "patient ontkent behandeling specialist";
specialistuitgevoerd = false;
akkoordgeven = "";
}else{

}
}

function aanvullenverzekeraar () payable{
verzekeraaraanvullenbasis = false;
verzekeraaraanvullenspecialist = false;
}

function clearstatussen (){
verzekeraaraanvullenbasis = false;
verzekeraaraanvullenspecialist = false;
huisartsuitgevoerd = false;
specialistuitgevoerd = false;
doorverwijzen = false;
akkoordgeven = "";
fraude = "none";
artsendecla = "";
}

}


texts: Verification of state deltas in rollup contracts

texts:
I have a question regarding how state data is verified by the L1 contract when an L2 rollup batch is published.
I understand that the state deltas are published in compressed form, as with a zk-rollup, where we replace addresses with leaf indices, and we remove the signature because they are verified in the snark / stark.  But how does the contract know if the CALLDATA payload that contains the compressed state deltas is accurate?  Is this data checked by the smart contract? i.e. does the smart contract hash each delta and create a merkle tree to compare to the public inputs of the snark?
If the smart contract doesn't check the calldata state deltas, then surely the operator can change the state history discretely?


texts: Convert Ethereum private key to public key (without network)

texts: Is there a calculation to convert Ethereum private keys to the public address, without being connected to the internet?


texts:
Is there a way to watch events from multiple contracts with just one watch-statement (something like [contract1.event, contract2.event, ...].watchAll() ) in Javascript?

Code is just for illustration purposes:

   var event = contract.EventName({from: address}); // watching multiple contracts/events possible?
   event.watch(function(err, result) {
         ...
   });


texts: Development approach to setup Eth account on Meteor/web3 app

texts:
I want to develop a Dapp that allows user to send and receive my own token (smart contract).

So far, I managed to setup a simple Meteor app that uses web3. So now it can interact with the smart contract which I deployed on a testrpc. The app can send/receive the token.

Questions are:

(1) What is the best or workable approach so that a user of my Meteor-web3 app can setup his/her ethereum account and eventually he/she can transacts with the token/smart contract?

(2) I am thinking to convert the Meteor-web3 to mobile Dapp. Is this even possible on the live Ehteruem network.

Thank you in advance for the guidance.


texts: How to best react to geth events from a server app?

texts:
I have a geth node running on a server. I want my Ruby app to take action every time a contract emits an event. The app cannot miss any events.

One way would be to poll for transactions to that address every x seconds, and scan the TX receipts for log data. Are there any Ruby tools to help with that? Is there a better way to do it?


texts: How to connect Trust Wallet in Javascript?

texts: I want to use TrustWallet for payments in my project for mobile users. I saw the documents related to TrustWallet web3 API but not getting how to use it in javascript. Can anybody help me with the javascript code connecting TrustWallet for mobile?


texts: Using Proof of Authority (similar to kovan and rinkeby testnet) in my private ethereum network

texts: Can one run a private proof of authority ethereum network? Similar to the kovan and rinkeby testnet.


texts: truffle - should I remember the results of previous calls?

texts:
I wrote a smart contract. now, I am writing tests in truffle .
the code is gonna look like this.
contract('contract', accounts => {
  it("test1", () => {

  })

  it("test2", () => {

  })

  it("test3", () => {

  })

})

Now, let's say I transferred 30 coins from accounts[1] to accounts[2] in test1 and in test1, I had a check for that and it asserted well. Now, in test2, I am testing different function, but that function still relies on the balance of accounts[1]. Now, it means that I should know what the balance was after the test1 ran. This is still fine, but then, in test3, I should know what the balance was for accounts[1] after test2 was run.
Problem 1: if some other developer comes and looks at this file, he can't really change something in test3, because if so, then he really has to know the results of accouns[1] from test2 which implies that he has to know results from test1. So, He has to understand everything..
Problem 2: If we decide that each it test of mocha is not dependent on each other, that means that, for each test, we should put each test in contract('contract') in order for truffle to start redeploying from scratch for each test. This is too time consuming and also,  each test will become TOO BIG. because now, test3 should include all the functions from solidity contract while in Problem 1, it would only have to include the function that it's going to test and test2 would take care of the previous dependent functions.
What's your recommendation ? or what am I doing wrong ?


texts:
I am trying to understand how to retrieve the complete storage of a contract based on chaindata (e.g. geth) of a full node.

I have already found how to programmatically access the chaindata (which is basically a levelDB) and the special trie structure:

https://github.com/ethereumjs/merkle-patricia-tree

Is this the way to go to get the contract storage?


texts: How can I use the fallback function to accept a payment?

texts:
I can't quite find the answer I'm looking for.

The gas limit for the fallback function is 2300.  Whether I call another method or set a variable, I blow WAY past the 2300 limit, rendering it useless.

Now, I've seen people suggest different ways to make the call and sending gas along with the call, etc., BUT I want someone to simply use the wallet.

Person A uses wallet to send the coin (presumably ether).
Fallback function accepts the ether and returns some tokens.

At no point is there a specific call to send extra gas, because I simply want to make this as easy for the user as possible.  Send ether via the wallet as they would normally send it to anyone.  In this case, when they send to a contract address, they get something for it.

Is this possible or am I spinning my wheels for nothing?

Thanks!


texts: Handling EOF when subscribing to Event Logs

texts:
I'm trying to subscribe to events logs to handle Transfer(address,address,uint64) events.  I've followed this example.

https://github.com/miguelmota/ethereum-development-with-go-book/blob/master/en/event-subscribe/README.md

However, when there are no incoming events I get an EOF error and the app quits. I tried to prevent the app quitting by removing the log.Fatal(err).  However, any subsequent JSON-RPC call to the blockchain will result in write tcp xx.xx.xx.xx:42542->xx.xx.xx.xx:443: i/o timeout errors.  Is there any way to close the socket gracefully without quitting the app?

Basically what I want to do is to continuously subscribe to the event and recover from any errors.


texts: Is it possible to deploy the ERC721 token on private network for free?

texts:
I created a private network with 3 instances (one controller, 2 nodes) based on PoA on AWS.
And I checked if my custom ERC721token is deployable by using Ropspan test network.
so I have a working-private network and a deployable smart contract.

But How can I deploy that contract on my private network?
Also, I have this question.
Is it possible to deploy ERC721 smart contract for free?

Please help me.


texts: how does calldata not work in this case?

texts:
pragma solidity ^0.7.4;

contract D {

    function test2(uint[1] calldata good) external {

        uint c = good[0];
    }

}

This code is perfectly valid. What I do is deploy it, then call test2 function from remix and pass [99] , then get the transaction hash and try to debug it. as soon as I click start debugging, Debugger just disappears completely.
What could be wrong ?


texts: erorr when writing a contract on mist wallet

texts:
I tried to make a contract to send token to many addresses at once, but when I want to make the contract have trouble in mist wallet, I have to use which contract code?

CODE :

pragma solidity ^0.4.16;

contract Ownable {

  address public owner;

  function Ownable() {
    owner = msg.sender;
  }

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

  function transferOwnership(address newOwner) onlyOwner {
    require(newOwner != address(0));
    owner = newOwner;
  }
}

interface Token {
  function transfer(address _to, uint256 _value) returns (bool);
  function balanceOf(address _owner) constant returns (uint256 balance);
}

contract AirDrop is Ownable {

  Token token;

  event TransferredToken(address indexed to, uint256 value);
  event FailedTransfer(address indexed to, uint256 value);

  modifier whenDropIsActive() {
    assert(isActive());

    _;
  }

  function AirDrop () {
      address _tokenAddr =0xe34c1960fbf05d4e08c19248491dfbcdbeab6e44; //here pass address of your token
      token = Token(_tokenAddr);
  }

  function isActive() constant returns (bool) {
    return (
        tokensAvailable() > 0 // Tokens must be available to send
    );
  }
  //below function can be used when you want to send every recipeint with different number of tokens
  function sendTokens(address[] dests, uint256[] values) whenDropIsActive onlyOwner external {
    uint256 i = 0;
    while (i < dests.length) {
        uint256 toSend = values[i] ;
        sendInternally(dests[i] , toSend, values[i]);
        i++;
    }
  }

  // this function can be used when you want to send same number of tokens to all the recipients
  function sendTokensSingleValue(address[] dests, uint256 value) whenDropIsActive onlyOwner external {
    uint256 i = 0;
    uint256 toSend = value;
    while (i < dests.length) {
        sendInternally(dests[i] , toSend, value);
        i++;
    }
  }

  function sendInternally(address recipient, uint256 tokensToSend, uint256 valueToPresent) internal {
    if(recipient == address(0)) return;

    if(tokensAvailable() >= tokensToSend) {
      token.transfer(recipient, tokensToSend);
      TransferredToken(recipient, valueToPresent);
    } else {
      FailedTransfer(recipient, valueToPresent);
    }
  }

  function tokensAvailable() constant returns (uint256) {
    return token.balanceOf(this);
  }

  function destroy() onlyOwner {
    uint256 balance = tokensAvailable();
    require (balance > 0);
    token.transfer(owner, balance);
    selfdestruct(owner);
  }
}

and for here, I include the address contract or the address that contains the token?

 function AirDrop () {
      address _tokenAddr =0xe34c1960fbf05d4e08c19248491dfbcdbeab6e44; //here pass address of your token
      token = Token(_tokenAddr);
  }


texts: Account import differs between eth and geth

texts:
I created an account with eth and ended up with a JSON file in the Web3 Storage Definition format.  After backing up this JSON file, I am able to delete my .web3 directory and reimport this JSON file into eth as I would expect.

Now I'd like to try geth with my existing account.  As I understand, geth account import expects not the JSON file, but rather a file containing just the "ciphertext" value from the JSON file.  Upon providing that, geth asks me to set a new passphrase, then prints the address of the imported key.

Problem: the address geth shows for my imported key is different from the address eth knows!  And when I view the JSON file that geth created from my import, its "ciphertext" value is different from the one I provided.

Question: Starting with the JSON file I have, how do I import my account correctly into geth?


texts: Do I need to sync with main ledger before mining

texts:
I am trying to setup ethminer to test some mining process. I am using the following guide
https://zeronumbers.com/node/32
In this guide the author did not mention anything like syncing up your system with main blockchain network like we do in dogecoin etc. Dont we do such thing with ethereum during mining?
Note. I have created a wallet on myetherwallet.com and using the address from there in my mining configuration.


texts:
Does ethereum geth compress old blocks in blockchain ?
Why I ask it: I saw that my blockchain has size on Disk around 40Gb, but once it down to 20Gb.


texts: Testing contracts that have construction parameters

texts:
How do I test a contract with that has construction parameters? For example what if I had slightly modified the metacoin example contract to include an initial_balance

contract MetaCoin {
  mapping (address => uint) balances;

  function MetaCoin(uint initial_balance) {
    balances[tx.origin] = initial_balance;
  }
  ...

How do I modify the example TestMetacoin.sol

import "truffle/Assert.sol";
import "truffle/DeployedAddresses.sol";
import "../contracts/MetaCoin.sol";

contract TestMetacoin {
  function testInitialBalanceUsingDeployedContract() {
    MetaCoin meta = MetaCoin(DeployedAddresses.MetaCoin());

    uint expected = 10000;

    Assert.equal(meta.getBalance(tx.origin), expected, "Owner should have 10000 MetaCoin initially");
  }
  ...

AFAIK the truffle test runner deploys the contracts and the Metacoin(DeployedAddresses.Metacoin()) gets the deployed contract to test.  But I don't see any way to pass in the initial_balance to test it.


texts: Return string (64 chars) to another contract in solidity

texts:
I have two contracts :

contract Child {

      mapping(string => string) private strings;

      function GetString(string key) public constant returns(string value) {
        return strings[key];
      }

}

contract Parent {

     Child c;

     function GetString(string key) public constant returns(string value) {
         return c.GetString(key);
     }

 }

I got a compilation error :

Return argument type is not implicitly convertible to expected type

I think this is a restriction of solidity that a contract cannot read a variable-sized data that is returned by another contract

Since my string can have more than 32 chars (i cannot use the bytes32 type), how can i achieve that ?

Thanks for your help !

MC


texts:
I want to turn my token from myetherwallet to real cash. How can I do that?

So for example if I send my Civic tokens to Coinbase, will they be automatically converted to Ethereum and I can withdraw the money from Coinbase? Is it ok to do that or it is not possible that way?

If not, what is the most efficient way of turning my tokens to real cash?

Thanks!


texts:
I've tried to git clone https://github.com/Giveth/minime.git, and had to search to find out how to give it a try.  Turns out I had to 'npm install minimetoken' which failed on Windows.  I don't know why.  The logs were not very helpful.

I tried on Linux, cloned the repo, and typed npm install minimetoken.  This appeared to install it in node_modules/minimetoken.  I still can't see how to run it or use it.

Is there a simple step by step guide for trying minime, then cloning a token with minime?

There are no really clear docs on making a token and testing it out as far as I can tell.  Any links appreciated.


texts: How to get the square root of a big number as returned by web3.utils.toBN()?

texts:
I'm working with big numbers as returned by web3.utils.toBN(). According to the web3 documentation, this function returns a BN.js instance. However, there doesn't seem to be a square root function on BN.js according to its documentation (https://github.com/indutny/bn.js/).
What is the best way to get the square root of a BN.js number?


texts: File import callback not supported in solcjs

texts:
Running E:\projects\Greeter-Contract-master\contracts>solcjs --abi Greeter.sol gives:

Greeter.sol:3:1: ParserError:
Source "contracts/Mortal.sol" not found: File import callback not supported
import "contracts/Mortal.sol";
^----------------------------^

Greeter.sol:

pragma solidity ^0.6.4;

import "contracts/Mortal.sol";

contract Greeter is Mortal {
    string greeting;
   constructor( string memory _greeting) public {
        greeting = _greeting;
    }

    function changeGreeting(  string memory _greeting) public {
        greeting = _greeting;
    }

    function greet() public view returns (string memory) {
        return greeting;
    }
}

Mortal.sol:

pragma solidity ^0.6.4;

contract Mortal {
    /* Define variable owner of the type address */
    address payable owner;

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

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


texts: Open Source Ethereum Blockchain Explorer

texts:
I am setting up a private blockchain with Ethereum Geth nodes. All work OK but there is no appropriate open source blockchain explorer for my private blockchain.

EtherChain Light is perfect but it only supports Parity Ethereum client not Geth Ethereum.

Could you please suggest some other blockchain explorers for my private blockchain? It would be better if it's open sourced.

Thank you!


texts: How to replace specific bytes at an index in a bytes32?

texts:
I have a bytes32 that I plan to pack with 10 bytes3 at specific indexes without affecting the other bytes already set. So for instance if I had a bytes3 of 0xABCDEF into bytes32 at the index 3, it will go from this:
0x0000000000000000000000000000000000000000000000000000000000000000
  ^0    ^1    ^2    ^3    ^4    ^5    ^6    ^7    ^8    ^9    ^ignore last 4 bits

to this:
0x000000000000000000ABCDEF0000000000000000000000000000000000000000
  ^0    ^1    ^2    ^3    ^4    ^5    ^6    ^7    ^8    ^9    ^ignore last 4 bits

I believe this could be achieved with some bitwise magic but I'm not too familiar with it. I found an example that sets individual bits and tried to tweak it to set more than just individual bits:
bytes32 currentBytesGroup;
currentBytesGroup = currentBytesGroup | bytes3(number) << (positionWithinGroup * 24);//3 bytes = 24 bits

however this doesn't appear to be working. What am I doing wrong?


texts: How to copy the data from a running private network to another

texts: I have two seperately running private ethereum networks,i want to copy the data from the first private network to the second one without stopping.I have tried multiple ways but was not successful.I will appreciate if someone can provide some guidance or hint on the best approach here.


texts:
I'm a bit new to the Solidity-thing and am asking myself the question what to do with functions that specify a certain (set of) return parameter(s) and then fail to compute/find the desired return value(s).
In Java etc, I'd return a null at this point or throw an Exception. Yet apparently, returning null is not an option in Solidity and Exceptions are only doable via revert().
Assume we have a struct and a mapping defined as follows
struct MyStruct(int x);

mapping (address => MyStruct) private;

and my function wants to return the data stored in the mapping for the requester's address - only if it is in the mapping. Now, in case this function would not have the requested data it would have to return an error or a null. In solidity, I see these two approaches to handle a case like this:

Create an empty struct object to return. Bad practice, I would say.

Use revert() to cancel further execution of the contract's code. Sounds reasonable as unnecessary Gas is not burnt. Anyhow, causes an error that needs to be caught and handled by the client logic.

Is there a more elegant way to do this?


texts:
I can't install solc on Mac OS X. I have tried the following:

npm install solc

/Users/punddalinni
└── solc@0.3.0-1
npm WARN enoent ENOENT: no such file or directory, open '/Users/punddalinni/package.json'
npm WARN punddalinni No description
npm WARN punddalinni No repository field.
npm WARN punddalinni No README data
npm WARN punddalinni No license field.

When I go back to geth, and I run

> eth.getCompilers()
[""]

When I tried to setSolc the following happened

> admin.setSolc('/Users/punddalinni/node_modules/solc')
exec: "/Users/punddalinni/node_modules/solc": permission denied
    at InvalidResponse (<anonymous>:-81662:-57)
    at send (<anonymous>:-156322:-57)
    at setSolc (<anonymous>:-133322:-57)
    at <anonymous>:1:1

I have tried following the directions here but it gets stuck at

brew install llvm --HEAD --with-clang

EDIT: Including contents of package.json from solc in Mac.

{
  "_args": [
    [
      "solc",
      "/Users/punddalinni"
    ]
  ],
  "_from": "solc@latest",
  "_id": "solc@0.3.0-1",
  "_inCache": true,
  "_installable": true,
  "_location": "/solc",
  "_nodeVersion": "4.0.0",
  "_npmOperationalInternal": {
    "host": "packages-13-west.internal.npmjs.com",
    "tmp": "tmp/solc-0.3.0-1.tgz_1457892692634_0.5487515390850604"
  },
  "_npmUser": {
    "email": "d11e9@turkd.net",
    "name": "d11e9"
  },
  "_npmVersion": "3.3.2",
  "_phantomChildren": {},
  "_requested": {
    "name": "solc",
    "raw": "solc",
    "rawSpec": "",
    "scope": null,
    "spec": "latest",
    "type": "tag"
  },
  "_requiredBy": [
    "#USER"
  ],
  "_resolved": "https://registry.npmjs.org/solc/-/solc-0.3.0-1.tgz",
  "_shasum": "523e79db0c69070f91fcbf408e8c7d0c93be176c",
  "_shrinkwrap": null,
  "_spec": "solc",
  "_where": "/Users/punddalinni",
  "author": {
    "name": "chriseth"
  },
  "bugs": {
    "url": "https://github.com/chriseth/browser-solidity/issues"
  },
  "dependencies": {},
  "description": "Solidity compiler",
  "devDependencies": {},
  "directories": {},
  "dist": {
    "shasum": "523e79db0c69070f91fcbf408e8c7d0c93be176c",
    "tarball": "http://registry.npmjs.org/solc/-/solc-0.3.0-1.tgz"
  },
  "gitHead": "5ce686c8d33db78c8f1eb8e2318eefbc5151f0eb",
  "homepage": "https://github.com/chriseth/browser-solidity#readme",
  "keywords": [
    "compiler",
    "ethereum",
    "solidity"
  ],
  "license": "MIT",
  "main": "index.js",
  "maintainers": [
    {
      "name": "chriseth",
      "email": "c@ethdev.com"
    },
    {
      "name": "d11e9",
      "email": "d11e9@turkd.net"
    }
  ],
  "name": "solc",
  "optionalDependencies": {},
  "readme": "ERROR: No README data found!",
  "repository": {
    "type": "git",
    "url": "git+https://github.com/chriseth/browser-solidity.git"
  },
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "version": "0.3.0-1"
}

Any ideas?


texts:
I have been getting the error:

  Failed to unlock account "" (no key for given address or file)

I did some reading and found that the problem could be caused by conflicting keyfiles. The solution was to specify the keyfile to use. How would I do that? I found the solution here:

  Error "no key for given address or file" when unlocking coinbase account

The command I am using is:

geth --datadir node1/ --port 30303 --rpc --rpcport 8545 --rpcapi "personal,db,eth,net,web3" --networkid 1 --unlock '0x""' --password passwords.txt --mine


texts:
I am working on a truffle dapp project. Other than init(), initWeb3(), and initContract(), I have been doing fine interacting with my contracts in several JavaScript functions, until I created my 9th function.
The "App.contracts.CONTRACT_NAME.deployed()" suddenly became unreadable on the web page. The console shows Uncaught (in promise) TypeError: Cannot read property 'deployed' of undefined.
It is weird because "deployed()" is recognized in all other functions, just in this one function that it isn't.
These are 2 of the 8 functions that "App.contracts.LandRegistration.deployed()" is doing fine:
getOnwersAddress: async function(element){
      let data = $(element).attr('data');
      let lanreg = await App.contracts.LandRegistration.deployed();
      let res = await lanreg.getLandOwner(data);

      //alert(res);
      $('.modal-body p').html(res);
      $('.modal').fadeIn(300);
  },

 checkCredentials: async function(acct){
     // console.log("account: "+ acct);
      let User = await App.contracts.User.deployed();
      let cred = await User.getCredential(acct);
      let LanReg = await App.contracts.LandRegistration.deployed();
      let cred2 = await LanReg.checkIfOwnerExists(acct);

      if (cred == "inspector"){
        console.log(cred);
        sessionStorage.setItem("account", cred);
        window.location.replace("inspector-home.html");
      }
      else if(cred2 == true){
        console.log(cred2);
        sessionStorage.setItem("account", "owner");
        window.location.replace("owner-home.html");
      }
      else{
        console.log(acct);
      }
    },

This is the function where it stopped working:
pullAssets: async function(){
    let LanReg = await App.contracts.LandRegistration.deployed();
    let assets = await LanReg.viewAssets.call();
    console.log(assets);
 },

This is the method in the Solidity contract I am trying to interact with:
   function viewAssets() public view returns(uint64[] memory){
        return (profile[msg.sender].assetList);
    }

I would greatly appreciate any help.


texts: Send json rpc request in Long connection

texts:
How can i send rpc request in long connection. Since the default rpc request using the short connection. When i send many requests together, the geth will break down with to many open file error, which means the number of connection exceed the limit.

So is there any way i can send request in long connection?