texts: Can't run truffle migrate if ganache-cli launched with --db option

texts:
If I run ganache-cli without options or any options except --db, and then run truffle migrate it will successfully migrate my contracts.

BUT

If I run ganache-cli --db ./ganachedata, and then run truffle migrate it will halt for a while and then crash with error:

Using network 'development'.
Running migration: 1_initial_migration.js
  Deploying Migrations...
  ... 0x2a1435cdef2ae87c905ed3d8e48a6011c56287fa9d2e8efc1fcdf32bbac979ab
Error encountered, bailing. Network state unknown. Review successful transactions manually.
Error: Contract transaction couldn't be found after 50 blocks
    at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:328377:30
    at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:64331:21
    at Array.forEach ()
    at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:64330:32
    at Array.forEach ()
    at Object.onMessage [as callback] (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:64328:22)
    at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:330526:20
    at Array.forEach ()
    at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:330525:12
    at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:176198:11

How to fix it? I need to save blockchain data so I need this --db option.

Btw MetaMask works fine with ganache-cli --db ./ganachedata.


texts: Convert old format kava tokens erc to new format

texts: I need help please, I bought KAVA TOKEN only when they came out, now I wanted to transfer them to another wallet but I notice, that his FORMAT will become obsolete, is there an option to convert them to a new FORMAT?


texts: How to create an ICO token that can be tradeable

texts:
How to create an ICO token with low fees that can be tradeable on decentralized exchanges.
E.g bob send 0.1ETH to the smart contract ,he receives the Eth for the ICO and can trade it, also the contract owner can withdraw the ETH or token sent to the smart contract


texts:
Hi I'm using rinkeby as test node for my mobile app. When I connect to node it need much time for sync mobile client with current head (especially on new accounts). Is there possibility not to download all blocks on mobile?

May be I'm doing wrong, but I can't do such thing as getting balance or making transactions without latest head.

UPD: I'm waiting while client.syncProgress returns not null variable. Then I request balance and get 0 value. But I have eth on the wallet.


texts: Does a symbol have to be unique in ERC721? How to find out a unique symbol?

texts:
As per the ERC-721 contract on OpenZeppelin, you can create a token with this constructor:

constructor(string _name, string _symbol) public {}

Does the "_symbol" have to be unique across the blockchain? If yes, then how can one find a unique public _symbol? Is there a public register maintained?

If it doesn't have to be unique, then a duplication of a contract with the same name and symbol, won't it confuse the people searching for your _symbol?


texts: geth peering between GCP VM and RPI failed

texts:
I have configured 3 ethereum nodes
2 in GCP VMS
1 in RPI
All are Ubuntu based
Miner1:
geth --identity "miner1" --networkid 42 --datadir "~/RPI/miner1" --nodiscover --mine --rpc --rpcaddr 0.0.0.0 --rpcport "8042" --port "30303" --allow-insecure-unlock --unlock 0 --password "password.sec" --ipcpath "~/.ethereum/geth.ipc" --rpcapi "db,eth,net,web3,personal,miner,admin,txpool,debug"
Miner2
geth --identity "miner2" --networkid 42 --datadir "~/RPI/miner2" --nodiscover --mine --rpc --rpcaddr 0.0.0.0 --rpcport "8043" --port "30304" --allow-insecure-unlock --unlock 0 --password "password.sec" --rpcapi "db,eth,net,web3,personal,miner,admin,txpool,debug"
RPI
geth --identity "node2" --networkid 42 --datadir "node" --nodiscover --mine --rpc --rpcaddr 0.0.0.0 --rpcport "8042" --port "30303" --unlock 0 --password "password.sec" --ipcpath "/home/ubuntu/.ethereum/geth.ipc" --rpcapi "db,eth,net,web3,personal,miner,admin,txpool,debug"
but admin.peers is successful between Miner1 and Miner2
But RPI is not peered.
GCP firewall configuration:
GCP Firewall settings
In GCP, top navigation->VPC Network->Firewall
Name=ethereum
Ingress
Tag name=miner
IP range=0.0.0.0/0
TCP = 30303,30304
UDP = 30303,30304
Create
In VMs, Edit VM
Network tag name = miner
Save VMs
Re-start VMs
In GCP, top navigation->VPC Network->Firewall
Name=allow-rpc
Ingress
Tag name=rpc
IP range=0.0.0.0/0
TCP = 8042,8043
Create
In VMs, Edit VM
Network tag name = rpc
Save VMs
Re-start VMs
Questions:

Why RPI is not peered with Miner1 and Miner2?
Any GCP firewall setting is missing?
Any UBUNTU ufw setting is required?

Update:
GCP VMs are getting peered with other 2 miners running on another Ubuntu PC.
So the problem is from RPI.
Some configuration is not correct.


texts:
I converted my ether to wether by sending ether to the contract (wether).

var send = web3.eth.sendTransaction({from:eth.coinbase,to:contract_address, value:web3.toWei(0.05, "ether")});

Now I want to convert back wether to ether. How can I do that?


texts: eg. Ether holders have a strong economic incentive to take any token protocol that works and port it directly to Ether.


texts: When we buy ETHERS at an exchange, how does it get added to the account in blockchain? I understand that the money (eg dollars) is for the exchange, but how does the exchange add it to the account in blockchain? Do they have special privileges on some special smart contracts which can add any number of ETHERS to an account?


texts: how to get previous transaction history for a particular address web3js1.0.0

texts:
web3.eth.getPastLogs({
    fromBlock : 3150168,
    toBlock : 3153168,
    address: "0xAD08C190Ed643ec60afBbAEB2E284F616F3C3b43",
    topics: [topics]
})
.then(result=>{})
.catch(error=>{})

how to define topics parameter?


texts: Comparing solidity sha3 with web3 sha3 inside smart-contract

texts:
The problem is that sha3 in solidity returns bytes32 and I have a string returned from IPFS by oraclize, and if hash calculated in solidity and returned to web3js (bytes32 got interpreted as a string) it equals web3.utils.soliditySha3, but I can't make that comparison inside solidity because of different types.
I tried converting bytes32 to string and vice versa in a few ways each, sometimes it doesn't work, sometimes they are not equal.

    bytes32 checkHash = keccak256(strConcat("0xf17f52151ebef6c7334fad080c5704d77216b732","570000000000000000"));
    var first = checkHash.toSliceB32();
    var second = form.toSlice();   // Returned from IPFS, it's a string that looks
        // like "0xd89a3fa2ddbed0a17fa2954b1060f41591c216155b688a7b5af5a2d7c003bb11"
        // checkHash returns the same string when pulling it out by web3js

So, I'm using this (https://github.com/Arachnid/solidity-stringutils) library to convert them both to slices and check by first.equals(second), and they are not equal.
I can't convert first slice to string, it says

  Error: Invalid UTF-8 detected

I tried function from here (How to convert a bytes32 to string), it says the same, tried

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

from here(https://gist.github.com/ageyev/779797061490f5be64fb02e978feb6ac), it converts it to something else. I guess I have no clue now on how it works.


texts:
I am having an issue deploying to ropsten. I am receiving an insufficient funds error but I believe my address to have ether on ropsten.

This command:

truffle migrations --network ropsten

Also Tried:
    truffle deploy --network ropsten

Note, the next commands deploy successfully:
    truffle deploy --network development
    truffle migrations --network mainnet

config:

'use strict';

const keys = require("./private.js");
let privateKeyMain = keys.main;
let privateKeyRopsten = keys.test
let mainApiKey = keys.mainApiKey
let ropstenApiKey = keys.ropstenApiKey
let mnemonic = keys.mnemonic
var HDWalletProvider = require("truffle-hdwallet-provider");

require('dotenv').config();
const Web3 = require("web3");
const web3 = new Web3();
const WalletProvider = require("truffle-wallet-provider");
const Wallet = require('ethereumjs-wallet');

/*
var mainNetPrivateKey = new Buffer(privateKeyMain, "hex")
var mainNetWallet = Wallet.fromPrivateKey(mainNetPrivateKey);
// var mainNetProvider = new WalletProvider(mainNetWallet, "mainnet.infura.io/v3/" + mainApiKey);

var ropstenPrivateKey = new Buffer(privateKeyRopsten, "hex")
var ropstenWallet = Wallet.fromPrivateKey(ropstenPrivateKey);
*/

var mainNetProvider = new HDWalletProvider(mnemonic, "https://mainnet.infura.io/v3/" + mainApiKey);
// var ropstenProvider = new HDWalletProvider(mnemonic, "https://rinkeby.infura.io/v3/" + ropstenApiKey);
var ropstenProvider = new HDWalletProvider(mnemonic, "ropsten.infura.io/v3/cb06dad7697b45b3999d15a8745be75c" + ropstenApiKey);/*
development: {
      host: "127.0.0.1",
      port: 8545,
      network_id: "*"
    },
mainnet: {
  provider: mainNetProvider,
  gas: 4600000,
  gasPrice: web3.utils.toWei("20", "gwei"),
  network_id: "1",
}
*/
module.exports = {
  networks: {

    ropsten: {
      provider: ropstenProvider,
      // You can get the current gasLimit by running
      // truffle deploy --network rinkeby
      // truffle(rinkeby)> web3.eth.getBlock("pending", (error, result) =>
      //   console.log(result.gasLimit))
      gas: 4600000,
      gasPrice: web3.utils.toWei("20", "gwei"),
      network_id: "4",
    },

  },

  compilers: {
    solc: {
      version: "0.5.0",
    }
  },

  solc: {
    optimizer: {
      enabled: true,
      runs: 1
    }
  },

  mocha: {
    reporter: 'eth-gas-reporter',
    reporterOptions: {
      currency: 'USD',
      gasPrice: 10
    }
  }
};

My error

Error:  * Deployment Failed *

"Migrations" could not deploy due to insufficient funds
   * Account:  0x1a3681a9f7A10210Ed71E867821543CC8c85c71b
   * Balance:  0 wei
   * Message:  insufficient funds for gas * price + value
   * Try:
      + Using an adequately funded account
      + If you are using a local Geth node, verify that your node is synced.

at /Users/jakemartin/.nvm/versions/node/v10.9.0/lib/node_modules/truffle/build/webpack:/packages/truffle-deployer/src/deployment.js:364:1
at process._tickCallback (internal/process/next_tick.js:68:7)

Truffle v5.0.5 (core: 5.0.5)
Node v10.9.0

It occurs during the deployment of migrations.

But if you look up that address at ropsten.etherscan, it has funds. Check for yourself! https://ropsten.etherscan.io/address/0x1a3681a9f7a10210ed71e867821543cc8c85c71b

I'm stuck - advice appreciated

----UPDATE-----

Now it just hangs...

Only things I changed are gasPrice and gas.

New ropsten config:

 ropsten: {
    provider: ropstenProvider,
    // You can get the current gasLimit by running
    // truffle deploy --network rinkeby
    // truffle(rinkeby)> web3.eth.getBlock("pending", (error, result) =>
    //   console.log(result.gasLimit))
    gas: 6500000,
    gasPrice: web3.utils.toWei("400", "gwei"),
    network_id: "4",
  }


texts: Do contracts have to implement the methods they inherit from interfaces, likewise, do they have to implement methods from abstract contracts?


texts: Any tutorial to How to self-host your own ETH

texts:
Yesterday I ask a Q to know if I can create my own self-host ETH and people come and create their tokens and I get answer YES!
And now I want to know how to do this?
Which repo I should clone?
Which commands I should use?
and...


texts: Can we resolve a contract address with ENS?

texts:
Is it possible to resolve a contract address with ENS?
The reason for the question: if so, then could someone just change resolving address pointing it to some other address?


texts:
pragma solidity ^0.4.0;

contract test {
    event test_value(uint256 indexed value1);
    uint256 value_test;

     function test_f()  {

        //value_test processing
        test_value(value_test); // log the current value
    }
}

In the above code, I am getting following error while compiling through Remix:

  browser/ballot_test.sol:1:1: SyntaxError: Source file requires different compiler version (current compiler is 0.5.1+commit.c8a2cb62.Emscripten.clang - note that nightly builds are considered to be strictly less than the released version


texts: Modeling real world contract with Ethereum with use of Ether transaction

texts:
I’d like to take advantage of the immutability and nonrepudiable nature of the blockchain.

Let’s say I enter into a bet with my friend that if it rains 10 days from now, I will pay him $100. If it doesn’t, he will pay me $100. In the real world, we would draft a paper agreement which both of us sign physically as proof.

How can this be done in the Ethereum world without involving the use of Ether? (except to pay for gas of course, we like betting with cash ;-) Can Ethereum be used to prove both of us entered into an agreement 10 days earlier? E.g. by storing in the blockchain the digital signatures of us signing a PDF agreement and saving such document on IPFS?


texts: Where does mapping store a variable if an address is already used?

texts:
I know that mapping use addresses, based on a hash of key + position of mapping storage variable

keccak256(bytes32(variable_address) + bytes32(key))

And I want to know where variable would be stored if this address is already used?? Yes, possibility of hash collision is really low, but it is still possible.


texts: How to mine a Empty Block or reject transaction?

texts:
How Can a miner can mine a empty block,reject honest transactions to be added into block ; does it mean we could tweak the miner client , if yes could someone tell how it is done and what are the commands to do it?

Thanks in advance


texts: Writing secure Smart Contracts in Solidity?

texts: With the DAO hack, it becomes even more important for developers to write secure smart contracts and be aware of pitfalls. Are there any good reference points/links which can describe the best practices around security of Solidity based Smart Contracts?


texts: When truffle migrate required account to be unlocked?

texts:
I've done several deployment using truffle, but it didn't ask me to unlock the account while deploying the contract on my private chain. But recently I have done one deployment and it asked me to unlock the account.
I was showing this error: Error: authentication needed: password or unlock
So, I'm wondering, in which case it asks to unlock the account and when it won't ask?


texts: Deploying and calling a contract works only with Ganache (not with Geth)

texts:
I deployed a HelloWorld contract using web3j and it worked awesome with Ganache. I was able to call my only function from the contract and it returns the desired result all the time.

When I deploy the contract to a private node created with geth, the transaction appears in pendingTransactions list and it returns the address of the deployed contract shortly after starting mining, but I cannot call the funciton. It always returns 0x (tested with both geth console and web3j). As you can see it is there.

 After starting the miner you can observe that it is successfully deployed:

This is the code that deploys the contract (it works with Ganache):

The problem is that every time when I want to call a function it returns 0x just like the contract is not there. I checked and geth manages to find the specific contract:

EDIT:

I used 3 methods to call the contract: Java code using web3j, Geth console and Remix ide.

1) As you can see the contract is deployed(it appeared at pending transactions and was added to the blockchain after I started the miner. The idea is that the result of the method is still empty string not "helloWorld")

2) From Geth console it fails to cast the value to BigNumber. I read somewhere that this might be because the node is not synchronized and it doesn't know what value to return, so it returns empty value.

3) From Java using Web3j

It throws an exceptions because the value returned is 0x and it fails to cast it:

Genesis.json

{

"config": {
    "chainId": 3792,
    "homesteadBlock": 0,
    "eip155Block": 0,
    "eip158Block": 0
  },
  "difficulty": "2000",
  "gasLimit": "3141592000000",
  "alloc": {
    "ca56bdff4ab30b96b4f618e718b88c7a1721ecc3": {
      "balance": "300000000000000000000"
    }
  }
}


texts: Getting ParserError eventhough semicolon is there

texts:
I am trying to make my own ERC-token on the ethereum network.

However, when I try to compile at Solidity I get this error:

browser/ballot.sol:121:9: ParserError: Expected token Semicolon got 'Identifier'
        name = "UFDADollar";                           // Set the name for display purposes
        ^

Here is the code:

function ERC20Token(
    ) {
    balances[msg.sender] = 1986000;               // Give the creator all initial tokens (100000 for example)
    totalSupply = 1986000                        // Update total supply (100000 for example)
    name = "UFDADollar";                           // Set the name for display purposes
    decimals = 0 ;                            // Amount of decimals for display purposes
    symbol = "UFDA";                               // Set the symbol for display purposes
}

Thanks for every answer.


texts: I want to understand something with BigNumber assertions

texts:
I have create a truffle project with a smartcontract and a test file.
Here is an extract of the test file:
expect(ret).to.be.bignumber.equal(new BN('42'));

ret is a value returned by a smartcontract's function i want to test. It is an uint256 value: 42.
It works fine but I have some questions in order to understand:

Why should i work with BN library ? Javascript does not support uint256 ? What is the difference with this (it works too):
 assert.equal(ret, 42);

Why 42 must be written as a string in BN constructor ? This is an integer, not a string...

Thanks


texts: How to find private key on build.secondstate

texts:
I'm a beginner in ethereum application developing. Actually I started some days ago with a book and now I tried to build my first smart contract using BUIDL, actually at this site: https://buidl.secondstate.io/.
I send 0.10$ to my default address, just to try to "deploy to the blockchain" setting provider, gas, and so on. It works. But what happens if I quit of that session?? I still have eth on my default wallet, I know that I can import it on another build instance, but how can I find the private key??

For example I want to import the Default account of the following image, how to do it?


texts: Having trouble verifying a contract on etherscan.io

texts:
I'm trying to verify a contract on etherscan.io.

The contract itself has a number of imports and libraries and has been deployed using certain constructor arguments.

I've copy/pasted the code from all the .sol files into the validation textbox on etherscan, have selected the same compiler version, but am not entirely sure how to provide the ABI-encoded constructor arguments.  Do they want the hex, JSON or what?

The code does not verify otherwise.


texts: Fictitious use case to send confidential data

texts:
I am designing the network architecture of a Fictitious agency that needs to send confidential data.
So my questions are:

Is it possible to send images through the Ethereum network? I've read that, for example, NFT's aren't stored on chain but with an external protocol IPFS. If I can't use the chain how do I link the IPFS with the Ethereum network?
Want kind of conditions can get a smart contract? For example, can I create a contract that send a image each time a certain condition is met in the image? Or is the smart contract limited to information on chain?

Any technical, network details (no implementation) would be welcome.
Thanks !


texts: Can a ethereum smart contract look up the current dollar/ether exchange rate and then change its behaviour depending on it?? and how?

texts:
can a contract on blockchain get outside data like "current dollar/ether exchange rate" using api like call??
If yes, how can it be done? and is there any technique to control the behaviour of the contract depending on outside factors like fluctuations in ether/ dollar currency?


texts: Several Ethereum projects use DSProxy to make their protocols more user-friendly. What is DSProxy exactly and how does it work?


texts:
I receive the input data as the image shows. And when I try to decode it with the method:

String inputdata = null;

Optional<Transaction> tx = web3.ethGetTransactionByHash(txHash).send().getTransaction();

if (tx.isPresent()) {
    inputdata = tx.get().getInput();
}

// DECODE
byte[] bytes = Hex.decodeHex(inputdata.substring(2).toCharArray());
System.out.println(new String(bytes, "UTF-8"));

this is what I have in the output:

So I wanted to know if there is another way to decode or what am I doing wrong to decode it?


texts: Can Solidity smart contracts send transactions on Ethereum?

texts:
I am trying to figure out whether Solidity smart contracts deployed on the Ethereum main net can send transactions. In other terms, can the address of a smart contract appear as the sender of a transaction?

I've already read this thread and the definition of Transaction presented in the Ethereum Yellow paper, but I am still quite confused...


texts: Is there a way to transfer my ETH from a cold storage to a hot storage without compromising it?

texts:
At first I wanted to use myetherwallet.com but now I am afraid the code may be hacked / corrupted some day.

The cold storage solution seems safer to store ETH in the long run.

While I understand how I can send ETH from a hot storage to a cold storage, I don't get how I could then transfer back my ETH to sell it for example, without compromising my cold storage by writing down my unencrypted key or my combo encrypted key + password on a computer connected to the internet.

Is there any way to do it or is there another way to securely store ETH?

Thanks


texts:
I am running Windows Seven Enterprise: wondering if someone can advise me on the following. I had Ethereum Wallet on C:\ with only 12 GB free. I moved the Ethereum folder to E:\ and tried to setup the blockchaindir on E:\Ethereum Wallet using geth.exe --fast --cache=1024 datadir=E:\Etherdata

The proces starts downloading and shows the following error/warning:

but seems to continue happily

and then quits / hard stop after like 2 minutes without any clear warning at the following screen:

Any advice is greatly appreciated, thanks!


texts: DApp Development- how to update dapp and keep existing data

texts:
Compare to web application that separate the application and database, we can update the application and keep the existing data.
Could you suggest me how to update dapp and keep the existing data?


texts: Should I make separate ERC20 wallets for each token?

texts:
When I create an Ethereum wallet on my hardware wallet (Ledger Nano), or a web wallet (Metamask), is it possible to mix UNI token and ETH together in that same single wallet address? Or must a separate ERC20 wallet be made for the UNI token? In other words, can Ethereum addresses contain a diverse collection of tokens, or is it only one token per wallet?
If so, what if I send a token like UNI to an ERC20 address that is filled with Ether? Is there an error or loss ?


texts: Myetherwallet issue with retrieving Rep Tokens after Augur's Crowdsale

texts:
We're trying to retrieve our augur tokens purchased in the crowd sale.

The balance shows up on etherscan/ethplorer, but when we follow augur's instructions re myetherwallet, the balance is 0.

Augur has stopped replying to our emails.

Thanking everyone in advance.

John


texts: Ubuntu 16.04: Truffle: command not found

texts:
I installed the truffle on my Ubuntu machine and it installed successfully but when i am trying to execute truffle commands it is saying;
truffle: command not found

I tried the solution mentioned in this question
Unable to install Truffle - Command Not Found

but it didn't worked for me.
I think the environment variable path is not set or there is some issue in node modules.

Please give a solution.
Thanks in advance.


texts: How to calculate exchange fee in ETH in transaction?

texts:
Let's say I have the following decoded transaction input data:

[
  "0x0000000000000000000000000000000000000000",
  "690000000000000000",
  "0xac709fcb44a43c35f0da4e3163b117a17f3770f5",
  "69000000000000000000",
  "3157593",
  "3268274872",
  "0x7d7a96a720396bb22681578545c56899f23f58e3",
  "27",
  "bdc6f8d14ade98f529d06fa1b1e85a9deb19df7a1621cc561a5167286d143885",
  "74e1206d9bdd7e39fad74991ad630fc424af1e34bf3c788aa22ac505804b9bd5",
  "100000000000000000"
]

that's used in trade method of this smart contract.

In this invoke the sender is willing to buy ARC (0xac709fcb44a43c35f0da4e3163b117a17f3770f5) token by selling ETH.

What I'm trying to calculate is how much ETH will be send to feeAccount; This line of code:

tokens[tokenGet][feeAccount] = safeAdd(tokens[tokenGet][feeAccount], safeSub(safeAdd(feeMakeXfer, feeTakeXfer), feeRebateXfer));

My calculations are:

const web3 = require('web3');

const feeMake = '0';
const feeTake = '3000000000000000';

let feeMakeXfer = (100000000000000000 * feeMake) / web3.utils.toWei('1', 'ether'); // 0
let feeTakeXfer = (100000000000000000 * feeTake) / web3.utils.toWei('1', 'ether')); // 300000000000000
let feeRebateXfer = 0;

let accountFee = feeMakeXfer + feeTakeXfer - feeRebateXfer; // 0.0003 ETH

So based on my calculations account fee for this trade is 0.0003 ETH.

Is it correct?


texts: Are events collected in Web3js asynchronously?

texts:
I am collecting a set of previously generated events, based on certain filters/test, and trying to display them on my HTML page. The code I am using to fetch the events is as follows:

var eventList = []
var myEvent = instance.EventName(
    {name: 'test name'},
    {fromBlock: 0, toBlock: 'latest'});

    myEvent.watch(function(error, result){
        if(result.args.cost > 100) {
          eventList.push(result);
        }
    });

When I try to view the values in eventList using console.log(eventList) on Chrome, I get an empty array represented as []. On clicking on the same, the array expands to show the actual values inside. However, this is accompanied by a message on the console stating "Value below was evaluated just now.".

I am unable to get the length of this array or loop over its contents as every time the array is seen as empty. This led me to believe that the values are somehow returned asynchronously by the Web3js watch function (Web3js v0.2.7).
I tried converting the array object into a string using JSON.Stringify(), however, it just returns [] instead of the populated array.

What is the reason for this behaviour and how would I convert the array into a concrete object such that I could iterate over its contents?


texts:
I want my users call a function and send some deposit to contract. I want them to chose whether they want to send ETH or ERC20 tokens. I have my code and I see no flaw in it. but how can I pass address(0x0) to remix UI? I mean if I want to send ETH, I need to set the token address to null or something.
if there is no option. is it possible to send address(0x0) using truffle?
contract SendEtherOrToken {

 function send(uint _value, Token _currency) public payable {
    if (address(_currency) == address(0x0)) {
        require(msg.value == _value, "ETH value doesn't match offer");
    }
    else { // use ERC20
        require(msg.value == 0, "ETH would be lost");
        require( _currency.transferFrom(msg.sender, address(this), _value),  "transferFrom failed");
    }
  }
}

I know, I can use a fake address and provide that option in my UI in case of sending ETH.
if (_currency == fake address) {accept eth} and then pass the fake address in UI when user chose the ETH pay option instead of Token. but, I don't want to do that.


texts: What is the definition of an Enode ID or Enode URI? What is it used for and how is it made?


texts: Trying to send balance to owner of contract

texts:
Code is:

pragma solidity ^0.4.16;

contract init {
        address owner;
        function init()
        {
            owner = msg.sender;
        }

        function send() public payable{
            owner.transfer(msg.value);

        }
}


texts:
Can I deploy a contract using the MetaMask console and if so, how?

Hi there,

I recently started testing the MetaMask console from Chrome (web3).

Is it possible to deploy a contract using the console only and if so, how would I go about it?

Something like this?

var contractInstance = MyContract.new([contructorParam1] [, contructorParam2], {data: '0x12345...', from: myAccount, gas: 1000000});

Can I deploy a contract from my local laptop as a text file?

Tera


texts:
Attempting to integrate my Veri into MEW, I get response that this is not ERC-20 token. I purchased on EtherDelta & my Veri still shows up there (my MEW wallet being serviced through MetaMask).

Does log-in make a difference? I'm using Private Key, do I need to log in using JSON?

Any guidance appreciated, thank you.


texts: How reliable is it to use Block number to calculate Time in Smart contract?

texts:
I have seen contracts use block numbers to manage when the crowdsale should start and stop. How reliable is this? I understand the average time in ethereum is 17secs between blocks, but can this be relied on as this can change in the future.

const startBlock = web3.eth.blockNumber + 2 // blockchain block number where the crowdsale will commence.

const endBlock = startBlock + 300  // 300 is little over an hour.

If this is avg 17 secs, can this be accurately use to give bonus slabs during the crowdsale? If not, what would be the best alternative?


texts: Convert contract creation code to contract source code


texts: cannot get return variable(s) in javascript when using require in solidity

texts:
I have a function in solidity that returns a few bytes32 variables.  I cannot for the life of me access those variables.  Can someone please help?

function getData() public returns (bytes32, bytes32, bytes32, bytes32) {
    require(approvedAccessors[msg.sender] == true);

    return (a, b, c, d);
}

then in my js file I tried:

static async getInitialProps(props) {
  const { address } = props.query;
  const myData = MyData(address);
  const tempData = await myData.methods.getPrivateData().call();

  return { address };
}

and this:

static async getInitialProps(props) {
  const { address } = props.query;
  const myData = MyData(address);
  await myData.methods.getData().call().then(function(v) {
    var res1 = web3.utils.hexToAscii(v[0].toString());

  })
  return { address };
}

I keep getting:

Couldn't decode bytes32 from ABI: 0x The size doesn't match.
Error: Couldn't decode bytes32 from ABI: 0x The size doesn't match.
    at SolidityTypeBytes.formatOutputBytes [as _outputFormatter]

After 2 days of debugging, I finally found the problem.  The problem is using require.

require(approvedAccessors[msg.sender] == true);

Without this line, the code works perfectly.  including this line will cause the above error.  I wonder if this is a bug.  I have checked that the condition is met.


texts: How to install solidity in Visual Studio?

texts:
I see microsoft visual studio now supports solidity and smart contracts deployments. The release notes state:

Creates project scaffolding with smart contract samples
Supports context sensitive menus for compilation and deployment of smart contracts.
Compilation generates both abi and binary files in the project ‘bin’ folder that are needed for deployment
The deploy option is tailored for the BlockApps STRATO instance
The deploy option automatically launches a self generated UI that can be used to test the smart contract
Generates automatic key upon first use and the default settings can be viewed on the project properties

But, I have Visual Studio installed. How to install solidity support and start developing / deploying smart contracts?


texts: How do I determine the maximum gas required for a truffle deploy?

texts:
I have a smart contract with some initialization logic and I'm trying to test it locally with truffle develop.

When I migrate, I run into:

Error: VM Exception while processing transaction: out of gas

Should I be setting a higher 'max' via this?

And if so, how do I determine what that should be (just for local development/testing)?


texts: What should be the gas and gasPrice for Ropsten Network in Truffle Config?

texts:
I just want to test my smart contract to be deployed in the Ropsten network, and I'm still puzzled on what should I put for the gas and gasPrice in the Truffle config. Thoughts about this?

ropsten: {
  provider: ropstenProvider,
  gas: 4600000,
  gasPrice: web3.toWei("50", "gwei"),
  network_id: "3"
}


texts: User anonymity while submitting data in smart contract

texts:
I've written a smart contract, that is a crowd sensing system. Where post posting a task user view that task and if they have what I'm asking for/and meet the task requirements they submit certain data.

My question here is, how can I ensure that the users that submit the data are kept anonymous? No one can link the data submitted to a particular user.

Is this doable, and any help with techniques I could use to achieve so?


texts:
I've been able to run truffle tests successfully using TypeScript, but when it comes to migration, I get stuck.
1) My current setup:
tsconfig.json
{
    "compilerOptions": {
      "target": "es5",
      "module": "commonjs",
      "lib": ["es6"],
      "allowJs": true,
      "outDir": "build",
      "rootDir": "src",
      "strict": true,
      "noImplicitAny": true,
      "esModuleInterop": true,
      "resolveJsonModule": true,
      "types": ["@types/node", "@types/chai", "@types/mocha"],
      "typeRoots": ["./node_modules/@types", "./types"],
    },
  }

truffle-config.js
require("ts-node").register({
  files: true,
});
//...

2) Migration files:
1_initial_migration.js
const Migrations = artifacts.require("Migrations");

module.exports = function (deployer) {
  deployer.deploy(Migrations);
};

2_deploy_contracts.js
module.exports = require("./2_deploy_contracts.ts");

2_deploy_contracts.ts
const Fallback = artifacts.require('Fallback');

module.exports = async (
  deployer: Truffle.Deployer,
  network: string,
  accounts: string[]
) => deployer.deploy(Fallback);

3) Problem:
I am using an intermediate file 2_deploy_contracts.js that is calling 2_deploy_contracts.ts, since Truffle apparently is ignoring the ts migration files.
Problem is that some types are not defined when trying to deploy the contracts:
$ truffle deploy --network development --reset
Error description:

migrations/2_deploy_contracts.ts:10:18 - error TS2304: Cannot find
name 'artifacts'.
10 const Fallback = artifacts.require('Fallback');
migrations/2_deploy_contracts.ts:13:13 - error TS2503: Cannot find
namespace 'Truffle'.
13   deployer: Truffle.Deployer,

Any idea on how to define types for artifacts and Truffle, or a workaround to run the migration files with TypeScript successfully?


texts: Unregistering a token in the Parity Token Registry

texts:
I am curious how to remove a token from the token registry in Parity. It is a token I have listed myself, and I am using the same address to try unregistering it.

I am using MyEtherWallet to send transactions, and the only piece of data I have to input for the transaction is the ID number for the listing (and I know I'm supplying the correct ID number).

When I look at my transaction on Etherscan, it clearly went through but there are no event logs or bad jump destination errors or anything like that.

What could I be doing wrong? And is there a place I can go to get better details on how to use the token registry dapp generally?


texts: Is it possible to connect with infura without a web3 provider?

texts:
I am trying to implement fallback funcationality for my DApp which means that when no web3 provider (e.g. metamask/trustwallet etc) is found I can still make calls to the ethereum network but I always seem to get the same issue.

This is my fallback logic:

 let bootStrappedWeb3;

  // Checking if Web3 has been injected by the browser (Mist/MetaMask)
  if (typeof web3 !== 'undefined') {
    bootStrappedWeb3 = new Web3(web3.currentProvider);
  } else {
    console.log('No Web3 Detected... falling back to using default mainnet HTTP Provider');
    bootStrappedWeb3 = new Web3(new Web3.providers.HttpProvider("https://mainnet.infura.io/<MY_API_KEY>"));
  }
  window.web3 = bootStrappedWeb3;

  // Listen for when web3 is connected and then bootstrap the app
  window.web3.eth.net.isListening()
    .then(() => {
      console.log('is connected');

      // Bootstrap the full app
      this.$store.dispatch(actions.INIT_APP, bootStrappedWeb3);
    })
    .catch(e => console.log('Something went wrong', e));

I see is connected and then INIT_APP is called.

INIT_APP then sets the provider on my truffle contract like this:

MyContract.setProvider(web3.currentProvider);

I can correctly read the current network which reports as on Mainnet, ID 1, but then whenever I try to use truffle this then falls over.

The call to truffle looks like this:

 MyContract.deployed()
    .then((contract) => {
      // Do stuff
    }).catch((error) => console.log("Something went bang!", error));

An exception is throw and I ass the error which is as follows:

Something went bang! TypeError: Cannot read property 'apply' of undefined
at Provider.sendAsync (contract.js?6b6f:24)
at RequestManager.sendAsync (requestmanager.js?e4d9:80)
at Object.get [as getNetwork] (property.js?7a8c:116)
at eval (contract.js?6b6f:512)
at new Promise (<anonymous>)
at Function.detectNetwork (contract.js?6b6f:503)
at Function.deployed (contract.js?6b6f:451)
at Store.eval (index.js?e3b1:444)
at Array.wrappedActionHandler (vuex.esm.js?edaa:704)
at Store.dispatch (vuex.esm.js?edaa:426)
at boundDispatch (vuex.esm.js?edaa:332)
at eval (index.js?e3b1:273)
at tryCatcher (bluebird.js?e531:5063)
at Promise._settlePromiseFromHandler (bluebird.js?e531:3095)
at Promise._settlePromise (bluebird.js?e531:3153)
at Promise._settlePromise0 (bluebird.js?e531:3198)
at Promise._settlePromises (bluebird.js?e531:3281)
at eval (bluebird.js?e531:162)
at MutationObserver.eval (bluebird.js?e531:4330)

Has anyone got any ideas? From the documentation and examples I have read I believe this should work, and and all help appreciated!

Thanks.


texts: Ownership trasfer to crowdsale contract fails while deploying in truffle

texts:
I have created a "Token" and the "Crowdsale" contract as mentioned in the openzeppelin. Below is my deployment code in truffle. I am new to ICO related coding and solidity. The question may be very simple but I am trying hard to find a answer, could you please assist?

Question

I understand the Crowd sale contract needs to have ownership of the token contract. Is it correct ?
If the ownership has to be transferred, how to do that while deploying itself ?

How to transfer the ownership of the token contract

2_deploy_ico.js

return deployer
.then(() => {
return deployer.deploy(SampleCrowdsaleToken, "Sample Crowdsale Token","SCT",18);
})
.then(() => {
console.log("Token Address : ",SampleCrowdsaleToken.address) ;
return deployer.deploy(SampleCrowdsale,openingTime,closingTime,rate,wallet,cap,SampleCrowdsaleToken.address,goal);
}).then(() => {
console.log("Sale Address : ",SampleCrowdsale.address) ;
// TODO: transfer ownerhship of the token to the crowdsale for minting
// Currently doing that in the UI
SampleCrowdsaleToken.transferOwnership(SampleCrowdsale.address);
console.log("!!! Success !!!") ;

});


texts: Why is the geth ipc file not being created, even though it says "endpoint opened"?

texts:
I had some test code working fine over IPC using out-of-the-box geth. I tried to set up a test network and it broke the IPC client.

I want to run two processes -- a miner geth process, which stands in for the community at large, and an IPC server geth process, which stands in for what would be running on my own web server.

Here is the script which captures what I think I should be doing.

#!/bin/bash

E="/store/ethereum/"

H="/store/home/"

D="$H/.ethereum-test"

G="geth --networkid 1100 --maxpeers 5"

PORT="--port 33301"

RPC="--rpcport 33302"

WSRPC="--wsport 33303"

IPC="--ipcapi 'admin,eth,miner,db,net,web3,personal' --ipcpath \"$E/geth.ipc\""

MINE="--mine  --minerthreads 1 -rpccorsdomain \"*\""

KS="--keystore \"$E/keystore\""

if [[ "$1" == "setup" ]]
then
    # Start fresh
    rm -rf "$D-miner"
    rm -rf "$D-client"

    # Accept conditions and type exit.
    $G --genesis test-genesis.json -nodiscover -maxpeers 0 --datadir "$D-miner" console
elif [[ "$1" == "newacc" ]]
then
    # Enter passphrase and note address.
    # Last generated address:
    # bcd47eee60f5d8f73977785a55ab081bf8f37582
    # 5b3e83ff30e61287cf2d8eed5b8c1ead40d10432
    # a770c607f4bde0cdf1fa84e8721e9b53fce8a176
    # (older)
    $G $KS --datadir $D-miner account new
elif [[ "$1" == "mine" ]]
then
    # Mine
    $G $MINE $KS --datadir $D-miner $PORT
elif [[ "$1" == "ipc" ]]
then
    $G --datadir $D-client $IPC
else
    echo "Argument: setup newacc mine or ipc"
fi

I use it like this.

In terminal A:

./testnet setup
./testnet newacc
./testnet mine

Mining works fine.

In terminal B:

./testnet ipc

This one appears to work fine. It outputs that it created $E/geth.ipc as promised.

Then here is the NodeJS which worked fine before:

var web3_extended = require ('web3_extended');

var options =
{
        host:     './geth.ipc',
        ipc:      true,
        personal: true,
        admin:    false,
        debug:    false
};

var web3 = web3_extended .create (options);

This yields

IPC Connection Error { [Error: connect ENOENT] code: 'ENOENT', errno: 'ENOENT', syscall: 'connect' }

What's odd is that geth in terminal B outputs this line

I0427 12:53:00.381003 node/node.go:298] IPC endpoint opened: "/ethereum/geth.ipc"

But if I ls /ethereum/geth.ipc

No such file is created (as it was with vanilla geth). Yes, I have write permissions to this directory. The miner in terminal A creates its geth.ipc elsewhere.

What's gone wrong?

EDIT

Miner produces this output when started with

geth --networkid 1100 --maxpeers 5 --mine --minerthreads 1 -rpccorsdomain "*" --datadir /ethereum/.ethereum-test-miner --port 33301

And IPC server produces this output when started with

geth --networkid 1100 --maxpeers 5 --datadir /ethereum/.ethereum-test-client --ipcapi 'admin,eth,miner,db,net,web3,personal' --ipcpath "/ethereum/geth.ipc"


texts: What wallet do support 25-word (24 words + extra word) seed phrases

texts:
I know only one wallet is supported 25 words seed phrase (24 words + extra word) is MEW.
Are there else wallets that support 25 words seed phrases?
UPDATE:
I'm interested in wallets what can import/export 25 words seed phrase like MEW.


texts: The cost of eth in the testnet is equal to the eth cost in mainnet?

texts: i´m new in Ethereum development, i´m developing a Dapp in the Ropsten testnetwork but i need to pass it to the mainnet, have the sames cost? are equivalent in the moment we pass the Dapp to the mainnet? Thank you very much.


texts: Is it dangerous to name my function ccccvKygDv?

texts:
For those keeping track at home, the function hash of a function named ccccvKygDv() is 0xffffffff, the same as a null address.

pragma solidity ^0.4.0;

contract NullFunction {
  function ccccvKygDv() public pure { }
}

contract NormalFunction {
  function NothingWrongHere() public pure { }
}

When I look at the opcodes of the two functions listed above, I get:

NothingWrongHere()

47 PUSH4 0xffffffff
52 AND
53 DUP1
54 PUSH4 0xb1f6260f

ccccvKygDv()

47 PUSH4 0xffffffff
52 AND
53 DUP1
54 PUSH4 0xffffffff

It looks like the data being pushed to the stack will overwrite some of the data needed for the function itself.

Is this a silly question? Absolutely, but I'm asking it so that I can understand how contracts work on the opcode level a bit better.


texts: Does MetaMask provide access to acount's keystore file?

texts:
I am looking for my account's keystore file. I know usually this is only available through geth.

MetaMask already provides the private key, but I'm not looking for the the private key, I'm looking for keystore UTC file.

Does MetaMask provide keystore access? If so where is its location?


texts: geth console - web3.isConnected function and not a function?

texts:
I am trying to find out if my node is connected. So I attach geth via geth attach in another terminal. But if I run web3.isConnected it returns
function(). But when I run it as a function web3.isConnected() I get an error 'isConnected' is not a function.

That's pretty weird behavior.


texts: How to set maximum block gas in ganache-cli

texts:
I'm running ganache-cli which seems to have a block gas maximum of around 6.5 million. All the research I've done about this question seems to provide answers of the user themselves setting the user gas LIMIT (not what I want) or setting a gas amount for the contract creation only, also not what I want.

What I have is a smart contract that I want to run millions of automated unit tests over in a "for" loop on the Solidity side. The smart contract contains randomness so each time it loops through a different result is output. I need to ensure over millions of unit tests that all the random results reach their expected value.

The problem is that I can only do about 20 "loops" before the 6.5 million gas is reached. I've tried doing a for loop on the web3 javascript side with Metamask however the problem here is that Metamask will pop up asking me to confirm the transaction every single time I want to run these 20 "loops". So 100 unit tests would require me clicking 5 times. A million? An awful lot.

How would I go about doing this? I thought if there is a way to increase the block gas maximum I might be able to increase my loop size to at least 1000 or so.

Or if you're aware of an alternate solution how I could automate millions of unit tests that would be great.


texts: Why isn't my contract getting a msg.sender? (solc 0.2.0-1)

texts:
TL;DR: Second's msg.sender isn't being set when it should.

Consider these two contracts:

First.sol:

import "Second.sol";

contract First {
  address public second;

  function First() {

  }

  function createSecond() {
    second = address(new Second());
  }
}

Second.sol:

contract Second {
  address public sender;

  function Second() {
    sender = msg.sender;
  }
}

When I send a transaction to First's createSecond(), then get the Second's address and try to get the sender of Second, I get 0x0 returned instead of an address.

Perhaps this is best shown in a test. Here, I'm using Truffle to run the test, and the First and Second objects are provided by Truffle through ether-pudding.

contract('First -', function(accounts) {
  it("Second should have an sender on creation", function(done) {
    var first, second;
    console.log("Creating first...");
    First.new().then(function(instance) {
      first = instance;

      console.log("Creating second...");
      return first.createSecond();
    }).then(function(tx) {
      console.log("Getting Second's address...");
      return first.second.call();
    }).then(function(second_address) {
      console.log(second_address);
      second = Second.at(second_address);
      console.log("Getting Second's sender...");
      return second.sender.call();
    }).then(function(sender) {
      console.log("SENDER ADDRESS:", sender);
      assert.notEqual(sender, "0x0");
    }).then(done).catch(done);
  });
});

Which produces this output:

Using environment test.
Compiling contracts...

  Contract: First
    Creating first...
    Creating second...
    Getting Second's address...
    0xbf12bb70b9bb9e1b58984a4ba5331a118d622d86
    Getting Second's sender...
    SENDER ADDRESS: 0x0
    1) Second should have an admin on creation.
    > No events were emitted

  0 passing (2s)
  1 failing

  1) Contract: First - Second should have an sender on creation:
     AssertionError: expected '0x0' to not equal '0x0'

So as you can see, Second's msg.sender isn't being set when it should. Anyone know why?

My environment:

OS X El Capitan
solc 0.2.0-1 via npm
Confirmed with ethereumjs-testrpc and Geth/v1.3.2-54904379/darwin/go1.5.1


texts: Can a decentralized exchange do secure price discovery for attacker-controlled tokens?

texts:
Imagine we have several different tokens, and we want to know which one is most valuable. Tokens are contracts with methods to satisfy the Token API.

If you have a decentralized exchange, you can put in a "buy" order at price X for a token, and if nobody is prepared to fill that order over a sufficient period of time anybody watching can conclude that the token is worth at least X. (You can manipulate this if you're prepared to spend enough buying your own token, but given enough liquidity making your token appear the most valuable should cost the market cap of the token that's really the most valuable.)

Is there a way to do this securely with arbitrary tokens (ie any code that satisfies the semantics of the Token API), or will that be impossible to secure? The kind of thing that occurs to me is that if the attacker can make the token contract themselves, they can prevent it from funding the exchange, so nobody is able to fill their offer. So I'm wondering if it's an inherently unsolvable problem, or if it's just that my decentralized exchange design is too dumb.


texts: How to send Ether to a contract successfully?

texts:
New to Solidity...

I am studying how to deposit Ether into a smart contract by setting a parameter in a function. Based on the value the function receives, the msg.sender is able to send a predetermined amount of Ether.

The idea is that if a value of 1 - 3 is provided, then 24, 12, or 6 Ether is sent from the msg.sender to the contract address. I set z = j to verify that the value was received by the function. Variable t is the value in Wei and is set to msg.value. It appears msg.value is properly set as the value of t gets updated according to the provided input value.

The issue I encounter is that Ether is not transferred when the function is called. Useful guidance would be most appreciated.

I am using Remix and have confirmed that all accounts have been unlocked.

Below is the source...

 pragma solidity ^0.4.18;

contract ETHTEST2 {
    mapping(address => uint256) public deposits; //depost

    uint256 public z;
    uint256 public t;

    function sendETHtoContract(uint256 j) public payable {  //msg.sender & msg.value test - Work in Progress

        if (j == 1){

            z = j;
            msg.value == t;
            t = 24000000000000000000 wei;
            address(this).transfer(msg.value);
            return;
        }

        if (j == 2){

            z = j;
            t = 12000000000000000000 wei;
            address(this).transfer(msg.value);
            return;
        }

        if (j == 3){

            z = j;
            t = 6000000000000000000 wei;
            address(this).transfer(msg.value);
            return;
        }

        if (j >=4 || j < 0){  //works
            revert();
            return;
        }

    }

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

    function() public payable {
    // this function enables the contract to receive funds
    }

}


texts: Multiple web3 instances on a Single Page

texts:
Is it normal/possible to use 2 instances of the web3 object?

In my app, a user can

trigger the deployment of new contracts by clicking a button on the UI. The gas comes from a wallet that belongs to the app
send ether to the deployed contract on the same page (made simple via a button on the page, contract then sends tokens to user)

In this scenario, is it recommended to have 2 web3 instances,

one using the web3 belonging to the app
one injected by the user's browser (eg: Metamask)

If so, is there a naming convention for the 2 web3 instances, like web3App and web3Browser?

Is this also an unusual scenario?


texts: Web3.js: Subscribe logs to get new contracts

texts:
I want to create a script that always notifies me if a new contract is created. My idea was to look for the "PairCreated" function. To validate if that is correct I have tested it with a simple RPC request to my Ankr endpoint with this params:
{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "eth_getLogs",
    "params": [{
        "fromBlock": "0x5B98A9",
        "toBlock": "0x5B98AA",
        "topics": [
            "0x0d3648bd0f6ba80134a33ba9275ac585d9d315f0ad8355cddefde31afa28d0e9"
        ]
    }]
}

It gives me this result:
{
    "jsonrpc": "2.0",
    "id": 1,
    "result": [
        {
            "address": "0xbcfccbde45ce874adcb698cc183debcf17952812",
            "topics": [
                "0x0d3648bd0f6ba80134a33ba9275ac585d9d315f0ad8355cddefde31afa28d0e9",
                "0x00000000000000000000000086c3e4ffacdb3af628ef985a518cd6ee22a22b28",
                "0x000000000000000000000000bb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c"
            ],
            "data": "0x00000000000000000000000042e32b5bdf0f249aefbee0f604be25e8fc81ac520000000000000000000000000000000000000000000000000000000000004d0e",
            "blockNumber": "0x5b98a9",
            "transactionHash": "0x83c03c35721f17e20af8e76e3c3fc29e9b8c20d3dde1e2a648f3556432d2c9ed",
            "transactionIndex": "0x15",
            "blockHash": "0xa400f21ed242eb893823d7c0e6bde7c9a4836c4e397128022a19a82fb2a0273d",
            "logIndex": "0x73",
            "removed": false
        }
    ]
}

The contract address in this case is "0x86c3e4ffacdb3af628ef985a518cd6ee22a22b28" (you can get it from results[0].topics[1]).
First question: Is this the correct way to get all contract addresses? Or are there contracts without a "PairCreated" log?
With this request I could determine the addresses of a certain block. Now I want to subscribe the logs to get all new contracts. I tried it like this with web3.js:
web3.eth.subscribe('logs', {
    topics: [
        // Pair created
        "0x0d3648bd0f6ba80134a33ba9275ac585d9d315f0ad8355cddefde31afa28d0e9"
    ]
}, (error, log) => {
    if (error) {
        console.log(error);
        process.exit(1);
    }

    console.log(log);
}).on("connected", (subscriptionId) => {
    console.log(`Connected with ID: ${subscriptionId}`);
}).on("data", (log) => {
    console.log(log);
}).on("error", console.error);

I have been running the script for a few hours now, but have not received a log yet. Maybe no contract was actually created in that time, but that would surprise me.
Second question: Is it possible that something is not yet correct here? How else do I always get the latest contracts?


texts: Is it safe to do multiple payments in between locks (Reentrancy Guard)?

texts:
https://diligence.consensys.net/blog/2019/09/stop-using-soliditys-transfer-now/ provides a simple example related to using a Reentrancy Guard.

  Another approach to preventing reentrancy is to explicitly check for
  and reject such calls. Here’s a simple version of a reentrancy guard
  so you can see the idea:

contract Guarded {
     ...

     bool locked = false;

     function withdraw() external {
         require(!locked, "Reentrant call detected!");
         locked = true;
         ... // Multiple Payments
         locked = false;
    }
}

But here I think there is another issue where if reentrant call is detected withdraw() fuction will be returned while locked remain true. Hence we will not able to re-enter into the withdraw() function in futher calls since locked remained as true.

[Q] Is it safe to do mutliple different payments in between the locks? An example will be as follows:

contract Guarded {
     ...
     bool locked = false;

     function withdraw() external {
         require(!locked, "Reentrant call detected!");
         locked = true;

         // Payment-1
         (bool success, ) = msg.sender.call.value(balanceOfPayment1[msg.sender])("");
         require(success, "Transfer failed.");
         balanceOfPayment1[msg.sender] = 0;

         // Payment-2
         (bool success, ) = msg.sender.call.value(balanceOfPayment2[msg.sender])("");
         require(success, "Transfer failed.");
         balanceOfPayment2[msg.sender] = 0;

         locked = false;
    }
}


texts:
Are there are any design patterns or gas efficient methods of mass updating user balances (for ERC20 tokens)?
For instance, say I wanted to run a casino where, after Block number X, all of the accounts such that Hash(Account address + hash of block number X) is even get one token added to their balance and if the value is odd, one token is deducted from their balance.
Are there any good methods out there for choregraphing such a process? The obvious way is to send a transaction after that block which updates all the balances, yet as the number of accounts becomes large, such a function call is very expensive. Any ideas? Thanks


texts: BTCRelay - What incentives do relayers have to submit accurate data?

texts:
It's possible I misunderstood how BTCRelay works, but relayers submit block headers to verify from Ethereum that transactions took place in Bitcoin. What prevents relayers from committing fraud by submitting false information as the block headers?

After enough blocks, with enough relayers independently submitting information, the system could find the inconsistency, but what prevents or discourages someone from submitting false information in the first place?


texts: fallback function how to call other function in contract?

texts:
When I send to contract address some coins, I want to call other function in fallback function, but I have encountered the followed error.

pragma solidity ^0.4.23;

contract Solitaire {
    uint randomNonce = 0;
    uint[] randomNumArray;

    event Deposit(address user, uint256 amout);

    constructor() public payable{
    }

    function GetNonce() public returns (uint) {
        return randomNonce ++;
    }

    function () public payable{
        uint value = GetNonce() + 20;
        emit Deposit(msg.sender, value);

    }
}

contract CallTest {
    event logSendEvent(address to, uint256 value);
    event depositvalue(address sender, uint256 value);

    function transferEther(address towho) public payable {
        require(address(this).balance > 100000000000000000, "Contract address does not exist enough money.");
        towho.transfer(100000000000000000);
        emit logSendEvent(towho, 100000000000000000);
    }

    function deposit() public payable {
        emit depositvalue(msg.sender, msg.value);
    }

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

    constructor() public payable{
    }
}


texts:
In "conventional", physical legal contracts, parties usually sign them with a handwritten/electronic/digital signature, depending on the form of the contract.

But as legal smart contracts are concerned, how are they signed by its parties? How is the consent shown/instrumented by part B to adhere to part A's smart contract? Are private and public keys used here?

Legally speaking, it's true that it would be recommended to initially give this consent in a previous contract (written in natural language) and just refer to the smart contract as a tool for implementing it... but let's assume this didn't happen and the smart contract is the only legal instrument.


texts: Does contract address support uppercase?

texts:
Does it support uppercase in web3.js? I write and deploy a test contract on rinkeby 0x7b84de0c31d308b42427d562306526e3eb95c825  if I change it to uppercase it return error Attempting to run transaction which calls a contract function, but recipient address 0x7b84de0c31d308b42427d562306526e3eb95c825 is not a contract address.

So I think contract address not support uppercase now.

I search like 'eth contract address uppercase' and read the wiki on github, but still not find any thing;

Can anyone give me an offical ansower ? and If it will support uppercase in future.


texts: How to build and sign a transaction to deploy a contract

texts:
I am trying to generate a transaction to deploy a smart contract on the chain and to sign it with web3js.

My problem is that I have no idea how to build the transaction object needed for the signTransaction function.

I first tried to create an object using the contract.deploy() function (without sending), but the transaction object needs a gas property, that the deploy() function does not create.

How do I create a transaction object that deploy a contract and how do I sign it with a private key?


texts: Funding with BTC to ETH in mist/ethereum wallet and not receiving Anything

texts:
I funded my ethereum acocunt with 1 btc.  I entered the "deposit address" into coinbase and it has since been confirmed over 500 times.  It says complete yet i dont see any ether in my account.

It is not synced and is taking multiple days to sync and I unfortunately had to restart so I am back to 1%, but does it have to sync to show the funds were received?
Is this normal?
Should I be worried my ETH is gone?

Thank you for your help


texts: Drizzle and mapDispatchToProps not working

texts:
I'm still struggling with Drizzle, trying to dispatch my own action. Based on the Drizzle box, I added the following to HomeContainer:

import Home from './Home';
import {drizzleConnect} from 'drizzle-react';
import * as actions from '../../store/actions/actions';

// May still need this even with data function to refresh component on updates for this contract.
const mapStateToProps = state => {
    return {
        accounts: state.accounts,
        SimpleStorage: state.contracts.SimpleStorage,
        TutorialToken: state.contracts.TutorialToken,
        Series: state.contracts.Series,
        drizzleStatus: state.drizzleStatus,
        rates: state.rates.ethRate
    }
};

const mapDispatchToProps = dispatch => {
    return {
        onGetEthRate: (fiatSymbol) => {console.log(dispatch); dispatch(actions.getEthRate(fiatSymbol));}
    };
};

const HomeContainer = drizzleConnect(Home, mapStateToProps, mapDispatchToProps);

export default HomeContainer;

The getEthRate action creator looks like this:

export const getEthRate = (fiatSymbol) => {
    console.log("Getting ETH rate for " + fiatSymbol);
    return {
        type: actionTypes.GET_ETH_RATE,
        fiatSymbol: fiatSymbol
    };
};

And then I registered a saga to process that action in rootSaga.js:

export default function* root() {
    yield all(
        drizzleSagas.map(saga => fork(saga)),
        takeEvery(actionTypes.GET_ETH_RATE, getEthRateSaga)
    );
}

But the following saga is never triggered, as I never see the log in the console:

export function* getEthRateSaga(action) {
    console.log("Fetching ETH rate for " + action.fiatSymbol);
    try {
        const response = yield http.get('/price?fsym=ETH&tsyms=' + action.fiatSymbol);
        const rate = response.data[action.fiatSymbol];
        yield put(actions.updateEthRate(action.fiatSymbol, rate));
    } catch(error) {
        console.error(error);
    }
}

And based on the Redux dev console, the GET_ETH_RATE action is not even dispatched, so I'm wondering if mapDispatchToProps works with drizzleConnect.


texts: Can we do ethereum transaction for free on private blockchain

texts:
I am very new to ethereum Blockchain. Please give some suggestion regarding one query regarding gas fee.

Can we do ethereum transaction and smart contract deployment for free on private blockchain using POA consensus  or still I have to pay ether(dummy ether)?
Thanks in advance


texts: We have an existing running ERC-20 token on main net whith around 200 holders . We would like to move to Binance smart chain or TRON blockcchain as it offers high throuhput and lower tx fees. How should I approach to move my existing ERC20 to another chain especially balances


texts: Error when estimating contract deployment fee using web3.eth.estimateGas

texts:
When I run the code line below:

let gasEstimate = web3.eth.estimateGas({from:myAddress, data: bytecode})

got and error:

> Error: Node error: {"code":-32000,"message":"gas required exceeds allowance (8000000) or always failing transaction"}

How fix it? many thanks.


texts: How can i publish smart contracts accessible from all client

texts:
I've developed a simple smart contracts with browser solidity:

pragma solidity ^0.4.9;

contract demo {
  string public name="Pietro";
  function changeName(string _newName){
       name=_newName;
   }
}

And published on Ropsten Testnet.

After that I've created a simple interface using meteor and web3.js that correctly alert the public variable 'name' stored on the demo smart contracts.
But this html interface is on my local computer.

So I want to publish that meteor project on my online website (linux server), and I want that all users can access (even if they don't have geth) to the public variable 'name'.
Is this possible and how can I do this?

Thanks


texts: How to update drizzle-box app to handle metamask no longer injecting web3?

texts:
I was reading about the latest and greatest metamask changes, and was wondering how I can update one of my dapps based off the truffle drizzle-box to be compatiable with the new metamask changes.

For one of my simplier dapps, I simply changed the load listener as needed.

Will I ever have to make any changes, maybe drizzle will be smart enough to prompt access to metamask?

See:

metamask-breaking-change I would prefer to fix this issue ahead of time.

drizzle box


texts: Modify Crowdsale when token is bought send same quantity to founders

texts: We're creating a crowdsale smart contract on ethreum and would like to know the code to modify the crowdsale such that when a token is bought, it also sends the same quantity of tokens to the founder's account so that they always control 50% of the project.


texts: How to call a function with ethereum alarm clock?

texts: In Ethereum alarm clock who is calling the contract (scheduler?) that executes the function programmed in my contract. I mean, I have a function in my contract that needs to run on a certain date, but who calls this function when the time comes? Which node? I don't understand if the timenode is the same as my node (geth / parity) or is it another ndo?


texts: How to interact with a smart contract in practice (for free)? A bigger picture!

texts:
At the moment I'm learning Solidity and using online remix to practice coding.

Question 1: As an exercise, can I construct a transaction and invoke my contract, for free (without inserting my contract to the block chain)?

Assume I have designed my contract and stored it in block chain.

Question 2:  Do I need to design a web API to let people/users use the contract? or Etherum provide an API?

In general, I'd like to have a bigger picture in designing smart contract, and see how different components fit together.


texts: ERC721-OpenZeppelin: This contract does not implement all functions and thus cannot be created

texts:
I know there are already a lot of topics that deal with the problem but their solutions didn't work for me.

this is the code:

pragma solidity ^0.5.2;

import "https://github.com/OpenZeppelin/openzeppelin-solidity/contracts/token/ERC721/ERC721Full.sol";
import "https://github.com/OpenZeppelin/openzeppelin-solidity/contracts/token/ERC721/ERC721Mintable.sol";

contract MyNFT is ERC721Full, ERC721Mintable {

  struct Structure{
      string name;
      uint id;
  }
  Structure[] public listOfStructure;
  address public owner;
  constructor() public{
      owner = msg.sender;
  }

  function create(string memory _name) public{
      uint id = listOfStructure.length;
      listOfStructure.push(Structure(_name, id));
      mint(owner, id);
  }

}

Remix says "This contract does not implement all functions and thus cannot be created.", I just started using nft so I know it could be a concept error, for example I didn't understand the concept of interface very well, but I don't think it's the same problem (maybe).

I tried to deploy with truffle but I have a similar error.

Thanks and sorry for the duplicate!


texts:
What can be the best way to get latest block data from geth ? I mean like can i use a script which gets the latest block automatically as soon as geth gets that latest block. My purpose is to check the latest incoming transaction ids inside each block.
Thanks!


texts: Confirmed transaction in Mist wallet multisig but it never goes away

texts:
I sent a transaction between two of my my wallets back in July. I confirmed the transaction and the Ether was sent. All is well. The only thing is the transaction continues to show at the top of my Mist Ethereum Wallet as pending. Any ideas how I can get rid of the "Confirmation Needed" notification?

Here's what it looks like:


texts: How Can I Retrieve Remaining Tokens from ICO Contract?

texts:
So I created an ICO contract based on a token with a set initial supply and no mint function.  I publish this contract and then send the associated tokens to the contract.  I can send ether and receive it in the desired account and the new tokens are sent to the correct account.

However, if not all of the tokens that were sent to the contract are purchased during the ICO, they just seem to disappear.  Is there a simple way to retrieve the remaining coins?  I have tried self destruct and suicide but I think those apply to the ether that would be stored in the contract address.

Thanks for any help!

Brian


texts: Why does remix not use contract source code for debugging?

texts:
Remix is the only symbolic debugger I know (debugging line by solidity line instead of by instructions).

But sometimes like with this transaction, the matching source code isn’t used for debugging, despite being compiled with the same compiler version.

How to force Remix to use a specific solidity source code (even if constructors don’t match) ?


texts: Double function style syntax in solidity

texts:
I was going through a code in solidity . Being a beginner I was completely flummoxed by the following line of code :

function foo()ParentToken(currentSupply,tokenName,decimals,symbol){}

Here I was unable to understand what this above line of code is intended for .

Is there any c++ analogy for this kind of construct in solidity language ?

I tried thinking about it as an overloaded () operator but could not make a fit .

Thanks in advance


texts:
I have already asked this question but I post once again as helpdesk people at ethereum are asking to post here:

After several years of waiting, I have decided to check how much ether I do have in my presale wallets. As I checked one of them with the address: 31680d74c182be56e3c122e37f3584ca480d528d

I am getting: No free outputs to spend.

The wallets were in a hidden location, encrypted. I haven't used them so far.

I would be thankful in case you can clarify this issue because then I would have lost my bitcoins which I used for this wallet.


texts: Contract functions. Is it possible to see contract exception detail?

texts:
Etherscan shows the following warning after I executed a function of my own contract.

Warning! Error encountered during contract execution [Bad instruction]

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

How can I debug it? Is it identify where the exception was thrown?


texts: What is the main use and purpose of Upgraded Standard Token?

texts:
contract StandardToken is BasicToken, ERC20 {

mapping (address => mapping (address => uint)) public allowed;

uint public constant MAX_UINT = 2**256 - 1;

function transferFrom(address _from, address _to, uint _value) public onlyPayloadSize(3 * 32) {
    uint _allowance = allowed[_from][msg.sender];

    uint fee = (_value.mul(basisPointsRate)).div(10000); //because 10000 Basis Points == 100% percentage terms
    if (fee > maximumFee) {
        fee = maximumFee;
    }
    if (_allowance < MAX_UINT) {
        allowed[_from][msg.sender] = _allowance.sub(_value);
    }
    uint sendAmount = _value.sub(fee);
    balances[_from] = balances[_from].sub(_value);
    balances[_to] = balances[_to].add(sendAmount);
    if (fee > 0) {
        balances[owner] = balances[owner].add(fee);
        emit Transfer(_from, owner, fee);
    }
    emit Transfer(_from, _to, sendAmount);
}

function approve(address _spender, uint _value) public onlyPayloadSize(2 * 32) {

    require(!((_value != 0) && (allowed[msg.sender][_spender] != 0)));

    allowed[msg.sender][_spender] = _value;

    emit Approval(msg.sender, _spender, _value);
}

function allowance(address _owner, address _spender) public constant returns (uint remaining) {
    return allowed[_owner][_spender];
 }

 }

contract UpgradedStandardToken is StandardToken{

function transferByLegacy(address from, address to, uint value) public;
function transferFromByLegacy(address sender, address from, address spender, uint value) public;

function approveByLegacy(address from, address spender, uint value) public;
}


texts:
I am just here to make sure that i understand what smart contract wallet and what wallet means. These 2 guesses of mine are highly related so what my question is simple. Am I right about assuming the below notes ?

Is it possible to write a wallet which supports transfering eth from your account to other account by just using web3 ? I guess yes, but that wallet would need the private key to sign a transaction. This type of wallet exists and it can exist without even any touch/interaction with smart contract. Am I right ?

There's another type of wallet we can write - smart contract wallet. Now, for the app, we still need web3, but now, our contract can have more features - multi confirmation, .e.t.c. We could have these advanced features if we didn't use smart contract wallet, just like in my first example, but in this case, the code of multisig code and many advanced features wouldn't be visible to the user and could be changed by whoever write it. With smart contracts, it's much much safer.


texts: Algorithm for quadratic voting in anonymous decentralized systems

texts:
The question is about voting in decentralized systems. Quadratic voting is a wonderful way to reach consensus without arranging property qualifications. However, quadratic voting requires a KYC: otherwise, the attacker will simply distribute his funds to many accounts and get many votes, bypassing the quadratic increase in their value (and get linear one).

Question: can a quadratic vote be modified to be used in decentralized way where all users are anonymous? Are there any other approaches for voting in such systems except the simplest - linear?


texts: Is there an Ethereum Testnet Android Wallet?

texts:
I am looking for a testnet-specific Android wallet app to load with a few Ropsten test Ether, for a web app I'm building. But for the life of me, I cannot find such an app for Ethereum.

For Bitcoin I'm using "MyCelium Testnet", but is there a testnet-specific equivalent for Ethereum? My web app generates a QR code for payment for a service, and I want to test it end to end.

Many thanks.
Russ


texts: Unable to collect metrics on my Geth node using default port 6060

texts:
I am interested in collecting metrics on my geth node (working towards getting a Grafana dashboard), but I'm currently unable to see stats when browsing to http://NodeIpAddress:6060/debug/metrics.
I followed instructions on the Ethereum blog post and have added two new flags --metrics --pprof to my startup script, which should put it on default port 6060.
Upon restarting my node, I see Enabling metrics collection in the logs, and no obvious errors.
Since I'm running on Ubuntu server, I have opened up my firewall on port 6060 using this command sudo ufw allow 6060/tcp and see via netstat that geth is listening on port 6060.
Unfortunately, when browsing to http://NodeIpAddress:6060/debug/metrics, I see an error ERR_CONNECTION_REFUSED. Any ideas what else I can do besides opening firewall to allow this connection?


texts: How to access array within a struct within an array?

texts:
I have a public array of structs. Each struct has a fixed-length array inside of it. How do I go about accessing a specific struct's array member via web3? The contract is compiling, but when I use the public array's getter function, it leaves the array member out.

Solidity:

pragma solidity ^0.4.21;

contract Foo {
    struct Bar {
        bytes32 a;
        uint8[9] b;
    }

    Bar[] public bars;

    function add(bytes32 _a, uint8[9] _b) public {
        bars.push(Bar(_a, _b));
    }
}

web3:

let foo = await Foo.new();
await foo.add("banana", [1, 1, 2, 3, 5]);
let bar = await foo.bars(0);
assert.equal(foo[0], "banana");
assert.equal(foo[1], [1, 1, 2, 3, 5]); // fails, returns undefined


texts: Cannot see ethereum in main account on mist wallet

texts: I created a mist wallet yesterday and sent some ethereum to the account address but I cannot see ethereum in the main account. Is there something I'm supposed to do in order to see the ethereum amount populated?


texts: Are these BTCQ tokens sent to contract properly locked?

texts:
In the case of this contract code, all the tokens sent to the contract are forever locked? Were they effectively burned?

I don't see any function like the solutions offered in this question, and I can't read the code well enough to tell, hence this question.

Here is the decompiled bytecode:

def storage:
  owner is addr at storage 0
  newOwner is addr at storage 1
  symbol is array of uint256 at storage 2
  name is array of uint256 at storage 3
  decimals is uint8 at storage 4
  _totalSupply is uint256 at storage 5
  balanceOf is mapping of uint256 at storage 6
  allowance is mapping of uint256 at storage 7

def name(): # not payable
  return name[0 len name.length]

def decimals(): # not payable
  return decimals

def _totalSupply(): # not payable
  return _totalSupply

def balanceOf(address _owner): # not payable
  return balanceOf[addr(_owner)]

def owner(): # not payable
  return owner

def symbol(): # not payable
  return symbol[0 len symbol.length]

def newOwner(): # not payable
  return newOwner

def allowance(address _owner, address _spender): # not payable
  return allowance[addr(_owner)][addr(_spender)]

#
#  Regular functions
#

def _fallback() payable: # default function
  revert

def totalSupply(): # not payable
  return (_totalSupply - balanceOf[0])

def transferOwnership(address _newOwner): # not payable
  require caller == owner
  newOwner = _newOwner

def safeSub(uint256 _a, uint256 _b): # not payable
  require _b <= _a
  return (_a - _b)

def safeAdd(uint256 _a, uint256 _b): # not payable
  require _a + _b >= _a
  return (_a + _b)

def safeDiv(uint256 _a, uint256 _b): # not payable
  require _b > 0
  require _b
  return (_a / _b)

def safeMul(uint256 _a, uint256 _b): # not payable
  if _a:
      require _a
      require _a * _b / _a == _b
  return (_a * _b)

def acceptOwnership(): # not payable
  require caller == newOwner
  log OwnershipTransferred(
        address previousOwner=owner,
        address newOwner=newOwner)
  owner = newOwner
  newOwner = 0

def approve(address _spender, uint256 _value): # not payable
  allowance[caller][addr(_spender)] = _value
  log Approval(
        address owner=_value,
        address spender=caller,
        uint256 value=_spender)
  return 1

def transferAnyERC20Token(address _tokenAddress, uint256 _tokens): # not payable
  require caller == owner
  require ext_code.size(_tokenAddress)
  call _tokenAddress.transfer(address to, uint256 value) with:
       gas gas_remaining wei
      args owner, _tokens
  if not ext_call.success:
      revert with ext_call.return_data[0 len return_data.size]
  require return_data.size >= 32
  return bool(ext_call.return_data[0])

def transfer(address _to, uint256 _value): # not payable
  require _value <= balanceOf[caller]
  balanceOf[caller] -= _value
  require balanceOf[addr(_to)] + _value >= balanceOf[addr(_to)]
  balanceOf[addr(_to)] += _value
  log Transfer(
        address from=_value,
        address to=caller,
        uint256 value=_to)
  return 1

def approveAndCall(address _spender, uint256 _amount, bytes _extraData): # not payable
  allowance[caller][addr(_spender)] = _amount
  log Approval(
        address owner=_amount,
        address spender=caller,
        uint256 value=_spender)
  require ext_code.size(_spender)
  call _spender.receiveApproval(address from, uint256 value, address token, bytes extraData) with:
       gas gas_remaining wei
      args caller, _amount, addr(this.address), Array(len=_extraData.length, data=_extraData[all])
  if not ext_call.success:
      revert with ext_call.return_data[0 len return_data.size]
  return 1

def transferFrom(address _from, address _to, uint256 _value): # not payable
  require _value <= balanceOf[addr(_from)]
  balanceOf[addr(_from)] -= _value
  require _value <= allowance[addr(_from)][caller]
  allowance[addr(_from)][caller] -= _value
  require balanceOf[addr(_to)] + _value >= balanceOf[addr(_to)]
  balanceOf[addr(_to)] += _value
  log Transfer(
        address from=_value,
        address to=_from,
        uint256 value=_to)
  return 1


texts: How can deployment through a contract factory be cheaper than deploying a contract directly?

texts:
When I deploy a contract directly, the transaction uses about 3,500,000 gas.

When I deploy the same contract through a contract factory, the transaction uses about 3,000,000 gas.

In the first case, I let the remix IDE set the gas amount. In the second case, I set the gas limit to 4,000,000 gas in MyEtherWallet. I don't think the gas limit should make a difference because the transaction should return any excess.

So, how is the contract factory reducing the amount of gas used?


texts: Is there a way to dynamically create a contract that points to a previous contract?

texts:
I would like to implement a tracking system .. where i track events between two parties who deliver an item between them .. then the receiver would deliver it to another person and so on...

I would like to create a contract for each transaction (between every two) at the same time , I would like to still be able to track all the chain .. the originator and the previous contract ...

Is there a way to do it ?


texts: How do I SendRawTransaction with document hash?

texts:
I'm a total newbie to blockchain and just started with it a week ago. I have already deployed a private Ethereum blockchain and want to use it to ensure document integrity which means that I'll be storing MD5 checksums on the blockchain to check at a later point in time.

Now I understand that a blockchain is not for storing data and one should use OP_RETURN to store such information if desired. This brings me to my question i.e. How do I create such a transaction and add the document's hash to it in OP_RETURN using:

A web3.eth object
Nethereum

Any and all help will be appreciated.


texts: How do I implement ERC20 token transfers with a button while not being the contract owner

texts:
Using web3 and setting metamask as the provider I want to be able to build a deposit function that takes a user's current metamask balance for a defined ERC20 contract and allows them to send that off to another wallet. This example is using ethjs as a convenience library.

How does the transfer function know that we want the user's metamask account to be the sender when our button is clicked. I've set the recipient address as the Ownerwallet since that is known ahead of time. Does Web3 automatically allow the transfer function from our contract to know who the sender(function caller is?).

var Web3 = require('web3');
var web3;

//metamask
  if (typeof window.web3 !== 'undefined' && typeof window.web3.currentProvider !== 'undefined') {
    var eth = new Eth(web3.currentProvider);
  } else {}

var TokenContractAddress = "0x...";
var Token = eth.contract(TokenABI, { from: accounts[0], gas: 3000000 });
var ContractInstance = Token.at(TokenContractAddress);

var OwnerWallet = "0x1...";

el('#depositTokens').addEventListener('click', function(){
   ContractInstance.transfer(OwnerWallet, el('#depositAmount').value)
    });


texts: Ether wallet IOS app with testnet functionality

texts: I'm trying to find an Ethereum wallet app on the apple app store to test my Dapp's QR code functionality but can't seem to find any wallet apps that support Ropsten. I've tried Ethers as they claim to do be able to do this but can't for the life of me see how to do it and think it might just not have been implemented. Thanks!


texts: How to generate truffle artifact for already deployed contract for use with web3

texts:
I'm building a dapp and would like to interact with an already existing contract.

Previously working with Truffle I was writing my own contract, compiling it and deploying it. This process generated a Contract Artifact that I could use with the truffle-contract library and make calls using web3.

How would I go about making calls to a pre existing contract that I never compiled and therefor don't have a Contract Artifact for?


texts:
What is the best way to revert inside a function if a particular condition is true? Sometimes safeguarding with require statements is not enough, i.e.

    uint256 constant public OFFER_LIMIT = 500 ether;

         function buyTheObjective(address _customer, uint256 _offer) internal returns (uint256) {
                require(limitRemovalDate > 0, "[!] Sale has expired" );

                // some code here which is only dependent of the require statement.
                //
                //
                if (now < limitRemovalDate && _offer > OFFER_LIMIT) {

                    // What is the best way to revert here?
                    // I want to reject people from overspending
                    // until a certain elapse of time.
                }


texts: Sweep funds from all accounts into one account

texts:
How can i sweep funds of all ethereum accounts into one eth wallet using web3 in ubuntu server?

Is there any example for the same? i found an example but that is not working for me.


texts: rafthttp: failed to find member 1 in cluster 1000 -quorum -raft consensus

texts:
Firstly, I  have created a node in quorum private blockchain  and initiated genesis to create blockchain using geth and bootnode . Then, I run the node and it is running blockchain. Later,  I tried to peer with the existing node,then I connected  it with  few  other   nodes it is working fine.(Genesis file, networkid is same for all enodes).
After that it is showing "leader is undefined" and
other error is "rafthttp: failed to find  member 1 in cluster 1000".
and another anomaly is  while adding the existing  peer to the cluster again (just to see its ID) it has created a raft id and appeared again in cluster(actually it should show the error but created twice the enode)

by looking into above you can see two times enode, raftid 4 and 12, created( I think it is bug in geth 20.0 version but later I have updated with geth 21 version). #how to resolve it

If I tried to remove the same enode    but it is displaying blank screen and same with other raftids. # how to resolve this error

if I tried to peer with the existing node  it is showing like this  failed to find member  . # how to solve this
my command to  this for connecting to peer
PRIVATE_CONFIG=ignore geth --datadir /home/ctquorumadmindev/QuorumChain/Test-Node2 --nodiscover --verbosity 5 --networkid 786 --raft --raftport 50501 --raftjoinexisting 2 --rpc --rpcaddr 0.0.0.0 --rpcport 8501 --rpcapi admin,db,eth,debug,miner,net,shh,txpool,personal,web3,quorum,raft --emitcheckpoints --port 25501 --ws --wsaddr 0.0.0.0 --wsport 8551 --wsapi=db,eth,net,web3,txpool,miner,admin,personal,web3 --wsorigins=*
my static node is this

main node //4ce4a5764647f418076a233a30fc34fcaa8f11d091440e5553c658d43faec60edc3992e373737716d6f4865b7606129ed1d5495819696216bd716960b20a341b is running but others are not connecting to this cluster above mentioned raft cluster is depicted for this scenario. # how to solve this
some other info  that may help you:
*multiple times I created raftId and removed it
*I tried to peer with new nodes it is showing same error
I have tried my best to explain current scenario, if any  extra info  needed I will be available to you


texts:
Any idea for the simplest way to add "degrees" variable into the string like below?
Looking for getString to return "today is 40 degrees outside".

 pragma solidity ^0.5.3;

        uint public degrees= 40;

        function getString() public view returns(string memory){
                string memory a = "today is ";
                string memory b = degrees;
                string memory c = "degrees outside";
                string memory sentence = string(abi.encodePacked(a, b, c));
                return sentence;
        }


texts: How do I read ALL of the data in a hashmap/array in a smart contract

texts:
To read from a mapping in ethers/web3.js, we do this:
const value = await myContract.someMapping(someKey);

We can search up one key/value in the mapping at a time. How can I get ALL values within the mapping instead of just one value? The same applies for arrays where you can retrieve one index of the array:
const value = await myContract.someArray(0);

How can I retrieve the entire array?


texts: how to connect ethereumj with private node

texts: I want to create a private blockchain network using EthereumJ and connect it to a project implementing EthereumJ. I tried modifying ethereumj.conf file but thats not working. How to do it?


texts: when uncle block info is recorded into blockchain irreversibly?

texts:
I want to confirm that what time is proper for checking there is uncle block or not.
I know that eth_getUncleCountByBlockNumber returns # of uncle blocks at a block number. (max is 2)
But when considering how ethereum handle uncle block, I think the timing of calling the method is very important.
For example, let's assume that latest block number of ethereum now is 20,000,000. And if I call the method at that moment, it returns 0 even if there may be uncle block in the future.
So which timing is safe for getting uncle block count in terms of confirmation?
Is it safe when I call the method with a block number of which confirmations is >= 12??


texts:
token.methods.balanceOf(accounts[0]).call().then(result=>{
    console.log(result);
   $creditsValue.innerHTML = result;
});

In this code when I try to fetch the balance from the contract dynamically it does not work and returns 0.
But when I check the balance manually it works like this:
token.methods.balanceOf('0xC9bb53aBc2DAA3726D6D2FD38B2664F2889EBb0d').call().then(result=>{
console.log(result);
$creditsValue.innerHTML = result;
});

Although the dynamic expression works fine in local network, but this problem is arising on the test network
Can someone please tell what's the problem it is urgent


texts: do I need to use ws provider in order to watch events?

texts:
I am using web3 version 1.0 version 26, however I can't receive any events from ganache-cli and testrpc.

  this.Contract.events.Created({},{ fromBlock: 0, toBlock: 'latest' }, function(error, event){ console.log(event); })
                        .on('data', function(event){
                              console.log(event);
                        })

this is my provider connection

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

is httpprovider not working for the watch events? do I have to use ws provider?


texts: Web3.js - where to find prepackaged bundle to be included with my HTML page

texts: Is there any way i can download web3.min.js and include "" in my html directly, without using npm to install, just like adding a js file, i know there is 0.20 version but i cannot find the version of 1.0 for web3


texts: transfer Erc-20 tokens from an adress without Eth and pay the gas from another adress or destination adress

texts:
as the title completely explains I want to transfer some erc-20 tokens from one account that has no eth in it to another how can I do so without need to deposit some eth to that account?
Is it possible that I pay the gas from destination account or other way?
Thank  you All


texts: My ETH Wallet was Hacked but I changed the login details

texts: If someone has hack your wallet before and they stole eth and you change your  details but not the address. Can they still hack your eth even if they only have the eth address?


texts: ParserError: Expected '{' but got 'constant' function totalSupply() public constant returns

texts:
i am having this error, at line 50 when i try to declare constant.
here is my code
    pragma solidity >=0.5.12;

contract SafeMath {

    function safeAdd(uint a, uint b) public pure returns (uint c) {
        c = a + b;
        require(c >= a);
    }

    function safeSub(uint a, uint b) public pure returns (uint c) {
        require(b <= a);
        c = a - b;
    }

    function safeMul(uint a, uint b) public pure returns (uint c) {
        c = a * b;
        require(a == 0 || c / a == b);
    }

    function safeDiv(uint a, uint b) public pure returns (uint c) {
        require(b > 0);
        c = a / b;
    }
}

contract ERC20Interface {
    function totalSupply() public constant returns (uint);
    function balanceOf(address tokenOwner) public constant returns (uint balance);
    function allowance(address tokenOwner, address spender) public constant returns (uint remaining);
    function transfer(address to, uint tokens) public returns (bool success);
    function approve(address spender, uint tokens) public returns (bool success);
    function transferFrom(address from, address to, uint tokens) public returns (bool success);

    event Transfer(address indexed from, address indexed to, uint tokens);
    event Approval(address indexed tokenOwner, address indexed spender, uint tokens);
}

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

contract LCSTToken is ERC20Interface, SafeMath {
    string public symbol;
    string public  name;
    uint8 public decimals;
    uint public _totalSupply;

    mapping(address => uint) balances;
    mapping(address => mapping(address => uint)) allowed;

    // ------------------------------------------------------------------------
    // Constructor
    // ------------------------------------------------------------------------
    constructor() public {
        symbol = "LCST";
        name = "LCS Token";
        decimals = 2;
        _totalSupply = 100000;
        balances[0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe] = _totalSupply;
        emit Transfer(address(0), 0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe, _totalSupply);
    }

    function totalSupply() public constant returns (uint) {
        return _totalSupply  - balances[address(0)];
    }

    function balanceOf(address tokenOwner) public constant returns (uint balance) {
        return balances[tokenOwner];
    }

    function transfer(address to, uint tokens) public returns (bool success) {
        balances[msg.sender] = safeSub(balances[msg.sender], tokens);
        balances[to] = safeAdd(balances[to], tokens);
        emit Transfer(msg.sender, to, tokens);
        return true;
    }

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

    function transferFrom(address from, address to, uint tokens) public returns (bool success) {
        balances[from] = safeSub(balances[from], tokens);
        allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
        balances[to] = safeAdd(balances[to], tokens);
        emit Transfer(from, to, tokens);
        return true;
    }

    function allowance(address tokenOwner, address spender) public constant returns (uint remaining) {
        return allowed[tokenOwner][spender];
    }

---------------
    function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) {
        allowed[msg.sender][spender] = tokens;
        emit Approval(msg.sender, spender, tokens);
        ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
        return true;
    }

    function () public payable {
        revert();
    }
}


texts:
Hello guys I have search around but no reasonable explanation as to why i would get these exceptions, I have already requested and have 3 ethers with associated with my address. Here is my code for sending ether:

private static void transferEther(String password)
            throws IOException, CipherException, InterruptedException, TransactionException {
        Web3j web3 = Web3j.build(new HttpService("https://rinkeby.infura.io/v1/c270b7df7bf54378a96ef7fe28e54715"));

    Web3ClientVersion web3ClientVersion = web3.web3ClientVersion().send();
    String clientVersion = web3ClientVersion.getWeb3ClientVersion();
    System.out.println("Connected to Ethereum client version: " + clientVersion);

    Credentials credentials = WalletUtils.loadCredentials(password,
            new File("/home/orchestra/Pictures/"
                    + "UTC--2018-12-12T07-39-27.54000000Z--ff1062eb9f9f4369780f8029fe60a5825eb943c9.json")
                            .toString());

    RemoteCall<TransactionReceipt> transactionReceipt = Transfer.sendFunds(web3, credentials,
            "0xf179233797511690a1254991d31f55598c3e34f4", BigDecimal.valueOf(0.2), Convert.Unit.ETHER);

    System.out.println("Funds transfer completed, transaction hash: " + transactionReceipt.toString());
}

but i get the following exceptions:

  Exception in thread "main" java.lang.NoClassDefFoundError:
  rx/schedulers/Schedulers  at
  org.web3j.protocol.rx.JsonRpc2_0Rx.(JsonRpc2_0Rx.java:39)   at
  org.web3j.protocol.core.JsonRpc2_0Web3j.(JsonRpc2_0Web3j.java:87)
    at
  org.web3j.protocol.core.JsonRpc2_0Web3j.(JsonRpc2_0Web3j.java:80)
    at org.web3j.protocol.Web3j.build(Web3j.java:21)    at
  CreateWallet.transferEther(CreateWallet.java:51)  at
  CreateWallet.main(CreateWallet.java:81) Caused by:
  java.lang.ClassNotFoundException: rx.schedulers.Schedulers    at
  java.net.URLClassLoader.findClass(URLClassLoader.java:381)    at
  java.lang.ClassLoader.loadClass(ClassLoader.java:424)     at
  sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)     at
  java.lang.ClassLoader.loadClass(ClassLoader.java:357)     ... 6 more


texts:
What makes Rinkeby a "testnet"? I understand it's a parallel network so my ether there has no effect on the mainnet ether. But how is it different technically?

But does it still run on miners? What incentive would miners have to maintain the testnet?

Could people simply decide that Rinkeby ether is not that bad and start trading it as a currency in itself??

Does it reset itself periodically?