texts: Can i call a function inside a created contract?

texts:
I have a structure similar like this typical Factory.

contract Factory {
  bytes32[] Names;
  address[] newContracts;

  function createContract (bytes32 name) {
      address newContract = new Contract(name);
      newContracts.push(newContract);
  }

  function getName (uint i) {
      Contract con = Contract(newContracts[i]);
      Names[i] = con.Name();
  }
}

contract Contract {
  bytes32 public Name;
  string public numberString;

  function Contract (bytes32 name) {
      Name = name;
  }

  function setNumberString (string time){
      numberString = time;
  }
}

I added to this structure the function setNumberString and the variable numberString, with Web3 js i have defined this:

myContract = web3.eth.contract(ABIArray).at(contractAddress);
myContract.setNumberString(state, function(error, result){
 if(!error)
     console.log(result)
 else
     console.error(error);
 })

The ABIArray and contractAddress are of the "contract Contract" created, and when i try to call the function, i obtain this message in the browser of the Dapp:

Uncaught TypeError: myContract.setNumberString is not a function

When i try to do this with a normal contract i don't have any problem, what i'm doing wrong? Is possible to call the function of this created contract?


texts: Is it possible to time a transaction such that it is the last in a block?

texts:
Is there some method to create a transaction and make sure that it is the last in that block? If not, how close can you get to being last?

The reason I ask is that the following page depends on that being the case:
https://github.com/slockit/dao/wiki/Why-The-Stalker-attack-is-a-non-issue

EDIT: By last in the block I mean that any transaction sent afterwards will be in the next block. Im not referring the ordering of transactions within a block.


texts:
While reading https://solidity.readthedocs.io/en/v0.4.21/abi-spec.html#abi I was just thinking what happens when calldata contains more parameters/data than the function expects (I know first parameter is 4 bytes Keccak256 of function signature, so this cannot happen by accident). It's just that you can use arbitrary msg.data. I believe those exta bytes should be just silently ignored (never referenced) or am I mistaken? This means the exact same function invocation can be encoded in many different ways.

Additionally: what happens if dynamic array "offset" points outside of the given parameters (or size is bigger than actual number of provided values). Can you imagine that everything undefined is sort of 0 or will such tricks throw an exception?


texts: Invalid Opcode when sending Eth to open zeppelin crowdsale on testrpc

texts:
I've been working on getting a crowdsale contract working using the Open Zeppelin library and Truffle for a couple of days now.

I can get the basic crowdsale working, but as soon as I try to implement a RefundableCrowdsale or CappedCrowdsale, the code stops working.

I can compile and migrate the code successfully using Truffle, but when I send funds to the contract account, I get the error:

  Error encountered, bailing. Network state unknown. Review successful
  transactions manually. Error: VM Exception while processing
  transaction: invalid opcode
      at Object.InvalidResponse (/usr/lib/node_modules/truffle/build/cli.bundled.js:37295:16)

Any ideas what could be causing this issue? Code for the crowdsale:

> pragma solidity ^0.4.15;
>
> import './CBIToken.sol'; import
> 'zeppelin-solidity/contracts/crowdsale/Crowdsale.sol'; import
> 'zeppelin-solidity/contracts/crowdsale/CappedCrowdsale.sol'; import
> 'zeppelin-solidity/contracts/crowdsale/RefundableCrowdsale.sol';
>
>
> contract CBITokenCrowdsale is CappedCrowdsale, RefundableCrowdsale {
>   function CBITokenCrowdsale(uint256 _startTime, uint256 _endTime,
> uint256 _rate, uint256 _goal, uint256 _cap, address _wallet)
>       CappedCrowdsale(_cap)       FinalizableCrowdsale()
>       RefundableCrowdsale(_goal)      Crowdsale(_startTime, _endTime, _rate,
> _wallet) {            require(_goal <=_cap);      }
>
>   //Create token  function createTokenContract() internal returns
> (MintableToken) {         return new CBIToken();  } }

and migrations:

const CBITokenCrowdsale = artifacts.require("./CBITokenCrowdsale.sol")

module.exports = function(deployer, network, accounts) {
  const startTime = web3.eth.getBlock(web3.eth.blockNumber).timestamp + 1 // one second in the future
  const endTime = startTime + 180//(86400 * 20) // 20 days
  const rate = new web3.BigNumber(1000)
  const goal = new web3.BigNumber(200)
  const cap = new web3.BigNumber(20000)
  const wallet = accounts[0]
  //const gas = 1000000

  deployer.deploy(CBITokenCrowdsale, startTime, endTime, rate, goal, cap, wallet)
};

Any help would be hugely appreciated!


texts:
How can I use ln -s to to make a symlink to the Geth chaindata on an external SD card?

I download the Geth chaindata to an external SD card to relieve the internal hard drive from the hard work.

However, I cannot start Mist when Geth is downloading the chaindata to an external SD card.

Luclu @ Ethereum confirmed that it should be possible to use a symlink to the SD card chaindata to allow Mist to run with this configuration.

What should the ln -s command look like?

OS: Ubuntu 15.10


texts: Would it be possible to kill Eth network with a lottery contract?

texts:
I've read about the problems of randomness in smart contracts (basically that a miner can decide not to publish the block if he doesn't win or benefit otherwise).

What if someone posted a lottery contract where anyone could participate, and the price was huge (for example millions of dollars worth of ETH). Could we expect all miners start to mine but decided not to publish if they're not winners? If so - are there any protections against such situation?

I imagine - if all miners started to do this and ignore the network, then some miners that decide to ignore the lottery would emerge. They will start mining transactions as usual and maybe get ahead of the "greedy miners".

At some point one "greedy miner" get's the block on top of the current blockchain where he wins (and other competing miners can decide to pursue, but their chance diminishes with each block).

1/ Is this path of thinking correct? Is this how the network would behave in an autocorrecting fashion?

2/ If that's the case - why should we worry about dishonest miners when implementing randomness in our contracts? (I must miss some crucial understanding here)

3/ And a bit more speculative question: would chase after lottery be any more profitable than just honest mining?


texts: Ethereum wallet income - transaction time

texts:
Can someone give me a hint please I'm new to Ethereum and I transfered/funded a small value of bitcoin (2 ETH) to Etherum official desktop wallet downloaded from GitHub and after I completed transaction on Blockchain it said funds are transfered to my Main Account (Etherbase) address the same address as mentioned on my desktop app it's been for an hour now but still says Balance 0.00 Ether on desktop application.

How long does it take for the Balance to get updated ?

Update

After reviewing my email I followed the link received from shapeshift.io from which I can see this picture:

As far as I see this address received ETHs but how do I get access to them if on my desktop wallet it still says 0 Balance. ?


texts:
How do I get the count of an erc20 token e.g. KNC of an address via Etherscan API?

Or is there another API that can do that?

thx


texts: I have a private blockchain, mined by one ec2 instance. When I restart the instance, significant part of the chain disappear with all transaction and contracts on it. How can I prevent this?


texts: Two transactions: same `from`, different `to`. What will happen?

texts:
Let's imagine that I've two pretty same transactions - the only difference is their to field. The first transaction - A, has 0x1111.... and the second one - B, has 0x22222.... in the to field.

If I'm sending them at the same time - what will happen? I see two different ways:

The "world" will be split in two parts: those nodes, who have received A at first and those, who have received B. So, depending on where "our" miner are - A or B will be mined, 50 / 50.
Ethereum nodes allows replacing transactions if they are not comfirmed. So, if a transaction is not mined yet, and node receives a new one - it replaces.

And the second question. Let's set the gasPrice for the B twice bigger than in the A.

I'm sending A
Waiting for e.g. 2 seconds
sending B

Does B have any chances to win this race? I mean, are there such rule like: "If there is a transaction from some address in tx pool, but there is another transaction from the same address and it's more expensive - first transaction should be replaced with the second one"

Thanks in advance!


texts: (Relatively) complex computations on private chain?

texts: Is there any way to get rid of gas limitations (or significantly increase them) to be able to do more or less useful stuff in smart contracts (such as RSA signature verification, defining advanced data structures, etc)?


texts: Running out of storage space - want to move Mist chaindata

texts:
I have a small laptop that I basically use for nothing but my Ethereum wallet, using Mist. I'm running out of space, so I added a 64gb SD card and I'd like to keep Mist running on the laptop but store the blockchain data to the SD card.

I followed instructions for making that change in Geth via terminal - designating --datadir to the directory of the SD card - but it doesn't seem to make any difference when I open Mist. The entries in the chaindata folder on my laptop's storage keep expanding and nothing appears on the SD card.
Does anyone know how to do this?


texts: Is there any way to diffuse the difficulty bomb and continue operating as though Ice Age doesn't exist?

texts:
I am running a private chain for my own purposes.  Rather: it's a "public" discoverable chain but not any known or publicized chain.

I want to continue to run this with PoW and no difficulty bomb.  Is this possible?  I had though I could do it with one flag in Parity, but this question suggests maybe not?


texts: How to deploy truffle contracts to Rinkebey?

texts:
What are the parameters that I have to specify to be able to deploy solidity contracts using Truffle in the config file? I am using Metamask to store test ether and have a unique mnemonic to define this in the config file.

Thanks


texts:
simnet is a feature of the Bitcoin client btcd, which allows a user to create a virtual test network where he can create blocks at ease.

Is there a similar feature for Ethereum/geth? What's the easiest way to test/try out a smart contract on a private test network?


texts: Off-chain database and access control management by smart contracts

texts:
I am thinking about an application which consists of two main components; off-chain database and ethereum blockchain for managing the accesses to the off-chain database. Is there any similar sample?
The main challenge for me is connecting the off-chain database to smart contracts. I am not sure using oraclize is an appropriate solution for this application. Do I need to write my own framework to forward requests from off-chain database to smart contracts? If yes can you help me how should I start?

I would be appreciated if you introduce some helpful sources.


texts: Initialize contract method on frontend and complete on server

texts:
I am creating a Dapp and using metamask. I want to approve the transaction cost on the front end using meta mask, from there I want to send the transaction hash to the backend and complete the transaction there. Is this possible to do with a contract method? I know its possible to do for a transaction like this:

Front-end:

const { raw } = await web3.eth.signTransaction({ ... });

Back-end:

web3.eth.sendSignTransaction(raw)

Is this possible to do with a contract method? I want to approve the gas transaction fee from the front-end.

Can I do it using myContract.methods.myMethod(123).encodeABI(); on the front end? And then send the ABI to web3.eth.signTransaction()?


texts: geth: How could I list already unlocked accounts?

texts:
I am using geth via third party application. I want to verify that specific Ethereum accounts are already unlocked or not, since unlocking an account can be timeout.

personal.unlockAccount(eth.accounts[0], "password");

[Q] Is there any way to verify that specific Ethereum accounts are already unlocked?

Please note that following script:

var Personal = require('web3-eth-personal');

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

if(!web3.isConnected()){
    console.log("notconnected");
    process.exit();
}

console.log(web3.personal

Returns, which does not have personal.listWallets:

Personal {
  _requestManager:
   RequestManager {
     provider:
      HttpProvider {
        host: 'http://localhost:8545',
        timeout: 0,
        user: undefined,
        password: undefined,
        headers: undefined },
     polls: {},
     timeout: null },
  newAccount: { [Function: send] request: [Function: bound ], call: 'personal_newAccount' },
  importRawKey: { [Function: send] request: [Function: bound ], call: 'personal_importRawKey' },
  unlockAccount: { [Function: send] request: [Function: bound ], call: 'personal_unlockAccount' },
  ecRecover: { [Function: send] request: [Function: bound ], call: 'personal_ecRecover' },
  sign: { [Function: send] request: [Function: bound ], call: 'personal_sign' },
  sendTransaction:
   { [Function: send]
     request: [Function: bound ],
     call: 'personal_sendTransaction' },
  lockAccount: { [Function: send] request: [Function: bound ], call: 'personal_lockAccount' },
  listAccounts: [Getter],
  getListAccounts: { [Function: get] request: [Function: bound ] } }


texts: How to allow each voter to vote only once? [Very Simple Voting Contract]

texts:
first, I apologize for this very very very simple question. I'm starting my studies on smart contracts, and after many attempts, I have not been able to solve this problem.
Objectively, this is a simple voting contract, with two candidates, A and B. The buttons add votes for each one.
 //Vote for candidate A or B
function VoteA() public {
    CandidateA++;
}

function VoteB() public {
    CandidateB++;
}

I would like to know how to ensure that each address can only vote once for each candidate. Only that!
I imagine that the solution goes through the mapping and array, but, all my attempts resulted in errors.
I apologize for the very basic question. Unfortunately, I am unable to resolve this issue even though I have consulted some similar topics.
Thanks!!!! Full contract follows
contract Election {

uint CandidateA;
uint CandidateB;
string Result;

//Vote for candidate A or B
function VoteA() public {
    CandidateA++;
}

function VoteB() public {
    CandidateB++;
}

//Function shows how many votes each candidate had
function getVotesA() public view returns (uint) {
    return CandidateA;
}

function getVotesB() public view returns (uint) {
    return CandidateB;
}

//Here the electoral commission determines the result
function CoutingVotes() public {
    if(CandidateA > CandidateB) {Result = "A Won";} else {
        Result = "B Won";}
}

//Here the electoral commission declares the result
function ResultElection() public view returns (string memory) {
    return Result;

}

}


texts: Are erc20's counted in market cap ethereum?

texts: Are all erc20 ethereum tokens backed by some deposit of ether to a contract? If so, is there an overlap in the market cap of the current 24 billion in ether and the value of all the erc20 tokens?


texts: Quorum :- metamask do not support privateFor feature of quorum

texts: i got to know that metamask do not support privateFor because  of which private transaction for quorum dapp was not behaving as expected. so, I can't use metamask for my quorum DApp to switch port and address. Is there any other wallet that support privateFor if not please suggest how can I change port and account address from DApp level?


texts: Contract kill/terminate with selfdestruct but also for tokens?

texts:
selfdestructs(owner) refunds Eth to owner. However, it does not transfer any tokens the contract may own. These would get permanently lost.

Would something like the following work? Is there a better approach?

contract Owned {
  address owner;

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

  modifier owner_only() {
    if (msg.sender == owner) {
      _;
    }
  }

  function terminate(address tokens[]) owner_only {
    // Transfer tokens to owner (TODO: error handling)
    for(uint i = 0; i < tokens.length; i++)) {
      address addr = tokens[i];
      ERC20Token token = ERC20Token(addr);
      uint256 balance = token.balanceOf(this);
      token.transfer(owner, balance);
    }

    // Transfer Eth to owner and terminate contract
    selfdestruct(owner);
  }
}


texts:
I have a Private Ethereum Network. I cannot mine using Parity, if I have a CPU node. Issue: How to do Ethash CPU mine using ethminer?

As a solution, I want to switch to geth node whenever I want to mine and switch back to Parity node if I do not need to mine.

In that case, I need to store the same blockchain for Parity and Geth processes, which is memory efficient.

Instead:

[Q] Can Parity and Geth work on a shared-blockchain?

For example, I can start my blockchain with Parity node, whenever I want to my I can switch back to Geth client and that will use the Parity's already created block chain. And when the mining completed I can switch back to Parity node again.

Please note that: I know that we can run Parity node and attach geth to use it as @Kannan Ravindran points in his answer. But when we do geth attach into an already running Parity node, we cannot execute miner.start() command, Parity does not allow us to do mining through geth.

Thank you for your valuable time and help.


texts:
There are many discussions about so called altcoins. Is Ethereum an alternative coin? Is Ethereum even a coin? (This is a canonical question to gether answers and resources on that subject.)

Is Ethereum a fork of or based on Bitcoin code?


texts: Metamask not connecting to ganache localhost

texts:
I am running a local ganache-cli and my metamask in my browser just keeps saying:
Oops! Something went wrong.

Here are the network details:
name: Localhost
RPC URL: http://localhost:8545
Chain ID: 1337

This started happening literally today, never had issues with it before. I don't think I changed any settings that would have affected this. I was just testing smart contracts locally like I normally do.
And my ganche-cli reflects this. I even make the JSON-RPC call for chainId, and this is correct.
Here is what I've tried:

Switching browsers (brave -> chrome)
Changing ports  on both the ganache-cli, UI, and metamask
Changing RPC_URL (to localhost, 0.0.0.0...) on both the ganache-cli, UI, and metamask
Using the ganache app
Uninstalling and reinstalling browsers
Uninstalling and reinstalling metamask
Turning computer off and on again
Resetting account in the advanced config

I'm losing my mind. I am able to deploy contracts to the ganache chain via the command line.
Here is what else I've looked at:
Metamask not connecting to localhost
http://asifwaquar.com/connect-metamask-to-localhost/
https://github.com/MetaMask/metamask-extension/issues


texts: Problem connecting a deployed smart contract to JavaScript. Remix + JS + Infura + Ropsten (with Metamask)

texts:
I am a beginner in DApps and still learning most concepts. Recently, I wrote a smart contract in Remix IDE which I deployed in the ropsten test network using injected web3 and metamask. The functions in the contract works fine and as expected. Here is the contract:
pragma solidity >=0.7.0 <0.9.0;

contract details {
    uint count=0;
   struct empDetails {
        uint date;
        string bank;
        uint BPay;
        uint allw;
        uint spallw;
        string status;
    }
    mapping (string => empDetails) AllDetails;

    function SetUserInfo(uint _date, string memory _empID, string memory _bank, string memory _status,
    uint _BPay, uint _allw, uint _spallw) public {
        AllDetails[_empID].date = _date;
        AllDetails[_empID].bank = _bank;
        AllDetails[_empID].BPay = _BPay;
        AllDetails[_empID].allw = _allw;
        AllDetails[_empID].spallw = _spallw;
        AllDetails[_empID].status = _status;
}

    function GetUserInfo(string memory _empID) public view returns (uint,string memory,uint,uint,uint,string memory)
    {
        return (AllDetails[_empID].date,AllDetails[_empID].bank,AllDetails[_empID].BPay, AllDetails[_empID].allw,
        AllDetails[_empID].spallw,AllDetails[_empID].status);
    }

}

I tried connecting it using web3 to a simple frontend that I am creating. Before using Ropsten, I tried deploying it on Ganache client and it worked fine. When executing the same code in Ropsten, I faced a lot of errors which I solved using other posts in this forum as reference. Here is the final code:
const Web3 = require("web3");
const Tx= require("ethereumjs-tx").Transaction;

web3 = new Web3(new Web3.providers.HttpProvider("https://ropsten.infura.io/v3/MY_ROPSTEN_API"));

var UserContract = new web3.eth.Contract(ABI, CONTRACT_ADDRESS);

var privatekey= new Buffer.from(PRIVATE_KEY, 'hex');

async function Submit(){

const myData= UserContract.methods.SetUserInfo(144447,"E102","ASBI","Working",30000,4060,5020).encodeABI();
const mynonce = await web3.utils.toHex(web3.eth.getTransactionCount(ACCOUNT_ADDRESS))
const txObject={from:ACCOUNT_ADDRESS,
gasPrice:100,
gasLimit:gasLimitHex = 300000,
nonce:mynonce,data:myData};

var tx= new Tx(txObject,{'chain':'ropsten'});
tx.sign(privatekey);
const serializedTx= tx.serialize();
const raw='0x'+serializedTx.toString('hex');
const transaction=web3.eth.sendSignedTransaction(raw,(err,txr)=>{

    if(err)
    {
        console.log(err);
    }
    else{
        console.log("It is Working "+txr);
    }
})

}
Submit();

I have only hardcoded the input parameter values for now. When I try running the Submit() function, I am getting a success message "It is Working" along with some other value which I am assuming is the transaction hash.
Sample Output:
It is Working 0x39418c22fc32c1670fcad9f9eba991976434b64bcf8a8ba0cf49ee1799efa90a
But I don't see any changes in Metamask or on Etherscan. I also tried running the getter function in the solidity contract using remix's own environment on the data that I hardcoded, but I am only getting a set of empty values.
Can someone help me understand what's going on and what I'm doing wrong?


texts:
I am using ethereum-ruby to deploy smart contracts. I am using JSON RPC calls to my geth and its working pretty well. But when i use compile_solidity I get:

"error"=>{"code"=>-32603, "message"=>"eth_compileSolidity method not available: solc (solidity compiler) not found"}}

and if I do get_compilers it returns "".

I installed solc it with npm. What am I missing?


texts: Does anyone have a smart contract that allows me to send to many recipients at once?

texts:
I just started using ethereum, so im not sure how smart contracts work and if this would be possible. Id like to be able to send ether and also cob from one account to a few hundred other accounts in a certain amount.

Can anyone help me with this? I need detailed instructions as im really new to this. thank you!


texts: Recreating a transaction from info in cancelled transaction

texts:
I created a transaction via a web app using metamask. I inadvertently cancelled that transaction. The web UI doesn't see that it was cancelled and will not let me recreate it, how can I take the data from metamask (or Etherscan) and manually resubmit the cancelled transaction.
Sorry not to include a link / tx, but I don't really want to dox myself.


texts: Is address.send() not vulnerable for the recursive call attack?

texts: If my dapp sends ether to another address via the send() method is it not vulnerable for the recursive call attack due to the limited amount of gas of 21000? Or should I still take precautions?


texts: Unable to schedule a call using Aion Recurring Contract

texts:
So here's the contract that I deployed on Ropsten Network. I took code refer from here.

pragma solidity ^0.4.24;

// interface Aion
contract Aion {
    uint256 public serviceFee;
    function ScheduleCall(uint256 blocknumber, address to, uint256 value, uint256 gaslimit, uint256 gasprice, bytes data, bool schedType) public payable returns (uint,address);
}

// Main contract
contract MyContract{
uint256 public sqrtValue;
Aion aion;
uint256 public myData;

constructor(uint256 number) public payable{
    scheduleMyfucntion(number);
    myData = 1;
}

function scheduleMyfucntion(uint256 number) public {
    aion = Aion(0xFcFB45679539667f7ed55FA59A15c8Cad73d9a4E);
    bytes memory data = abi.encodeWithSelector(bytes4(keccak256('myfucntion(uint256)')),number);
    uint callCost = 200000*1e9 + aion.serviceFee();
    aion.ScheduleCall.value(callCost)( block.timestamp + 10 minutes, address(this), 0, 200000, 1e9, data, true);
}

function myfucntion(uint256 number) public {
    // do your task here and call again the function to schedule
    myData = myData+1;
    scheduleMyfucntion(number);
}

function getMyData() view public returns (uint256) {
    return myData;
}
function () public payable {}
}

The purpose of this contract is to schedule a call in every 10 minutes.

Expectations: myData variable should be incremented by one in every 10 minutes.

Actual: Unable to see any new transaction after successful deployment. Nor able to see the variable being incremented ever.


texts: I wonder if aside the Json representation of ABI is there a bytecoded and compact version of the same interface. Json is human readable, but in some cases it is just an overkill.


texts: Does Mist Wallet support transfer of Ether through a Smart Contract?

texts:
I have implemented a private ethereal blockchain. I have also deployed a simple trading smart contract. It runs fine once deployed through MIST wallet. The problem is that it does not subtract ether from the buyer's account and also does not add the ether paid by the buyer to the Seller's account. Once the Buyer's Contract Transaction is mined, the status in MIST Wallet while receiving the mined confirmations, does show that -120 ethers (e.g it is the cost of a product that buyer has paid via payable function).
What can be the reason that MIST wallet is not adding or subtracting ethers from wallet accounts based on smart contract transactions?


texts: How to check if a contract has a method?

texts: Given a valid contract address how can I check if the contract implemented a certain interface i.e Ownable?


texts: Facing an issue in transaction signature generation using a C library

texts:
I'm trying to generate a signature for a raw transaction using an ECDSA library implemented in C.

Here are the transaction parameters:

const txParams = {
    "nonce": "0x05",
    "gasPrice": "0x0ba43b7400",
    "gasLimit": "0x5208",
    "to": "0x9fbad6ab4b240d7512f863753ad3449f9ad6a530",
    "value": "0x0de0b6b3a7640000",
    "data": "0x",
    "chainId": 4
}

Then I'm generating the RLP encoded Keccak256 hash of the transaction
parameters. Below is the RLP hash:

ad7de070ee104a433e37298f70feb6af08da26287efff6af2b25bbf64a56b70b

All of the steps upto here are done using the ethereumjs-tx library.

In the C program I convert the RLP Hash to byte format and store in a byte array.

static uint8_t m_hash[] =
{
  0xad,0x7d,0xe0,0x70,0xee,0x10,0x4a,0x43,
  0x3e,0x37,0x29,0x8f,0x70,0xfe,0xb6,0xaf,
  0x08,0xda,0x26,0x28,0x7e,0xff,0xf6,0xaf,
  0x2b,0x25,0xbb,0xf6,0x4a,0x56,0xb7,0x0b
};

This is then signed using the private key.

The output signature is always different each time I run the program, and below are a few samples.

29C1C06C3E60D5BD51F9F803AEE5193ACABFFD6B45FAC48C7DDE737427FB7F2C643B35FABB633E6A6B6ABC52F7907D245457ECAE5F2372D3D6A85BC2B68A4DF0

64FE2A3AF423642EFC989BAD1503CEA2637FC5543963E64F95A0644942D96EF5663267511DB6A8853E666F1877ACEAC86470DF8A710D844177E66DE4A158F0EA

B3C2DA2C5800FE4773BECF5A0690041483AB6C551A8DE6CCB84FD07EDD09857B3B2AAFA0BA268A4B7178B260C8A79BC86EFF60A55D60EFD11247632A9AB11382

I then use the sign function of ethereumjs-util to parse this signature and encode it into v, r, s values.

To calculate v, I've tried out different values of the recovery id in the range 0 - 3 which I directly enter in the sign function of ethereumjs-util, which looks like this.

exports.ecsign = function (msgHash, privateKey) {

  // -------------------------------------------------
  // Original Implementation

  // var sig = secp256k1.sign(msgHash, privateKey);

  // --------------------------------------------------

  // --------------------------------------------------
  // My changes

  var sig = {
    signature: "",
    recovery: 0
  }

  var signature = "29C1C06C3E60D5BD51F9F803AEE5193ACABFFD6B45FAC48C7DDE737427FB7F2C643B35FABB633E6A6B6ABC52F7907D245457ECAE5F2372D3D6A85BC2B68A4DF0"

  sig.signature = Buffer.from(signature, 'hex');

  // --------------------------------------------------

  var ret = {};
  ret.r = sig.signature.slice(0, 32);
  ret.s = sig.signature.slice(32, 64);
  ret.v = sig.recovery + 27;
  return ret;
};

This returns the signed transaction which I then serialize and try to broadcast to the ethereum blockchain

0xf86c05850ba43b7400825208949fbad6ab4b240d7512f863753ad3449f9ad6a530880de0b6b3a7640000802ca029c1c06c3e60d5bd51f9f803aee5193acabffd6b45fac48c7dde737427fb7f2ca0643b35fabb633e6a6b6abc52f7907d245457ecae5f2372d3d6a85bc2b68a4df0

At this point I get an error, stating "Invalid sender".

Can someone help me with what I'm doing wrong here?


texts: solidity function works perfectly in remix but in react application it is not executing in the same way

texts:
in Remix i execute it and it works as i expecting and when i check the value from other function it returns the expecting value

function makeadmin(string memory cityN, address adminAdress, string memory AdminName,
string memory hash) public
    {
        require(msg.sender==0x20db1A3eD27EEF75BEBb000961d07AD47Bf58197);

        require(!(ch[cityN].AAdminAdress==adminAdress ));
         require(!(adminscitystatus[cityN]));
        require(!(adminsaddressstatus[adminAdress]));

        ch[cityN].CCityName=cityN;
        ch[cityN].AAdminAdress=adminAdress;
        ch[cityN].AAdminName=AdminName;

        ch[cityN].hashh=hash;
          ch[cityN].noofadmins.push(adminAdress);
        ch[cityN].adminsid[adminAdress]=ch[cityN].noofadmins.length-1;
      adminscitystatus[cityN]=true;
        adminsaddressstatus[adminAdress]=true;
        cityforcompany.push(cityN);
        uint comid=cityforcompany.length-1;
        companycityid[cityN]=comid;
    }

In React js it is not adding the value to respective variables in solidity contract and the variable res returns something like Result[] __proto__.constructor with 0 length

async SubmitData4 (e) {
      e.preventDefault();
      await window.ethereum.enable();
      var Acc= await web3.eth.getAccounts();

      console.log('acc',Acc);

      var res= await LandAbi.methods.makeadmin("muree","0x8057450DFC37633CF19fbaC32E1eF30E44B36007","muneeb","sdasere4e4fre").call({from: Acc[0]});

console.log("res",res);

}


texts: Function call executes modifier function midway through the method instead of at the beginning of the call

texts:
using SafeMath for uint256;
using SafeMath32 for uint32;
using SafeMath16 for uint16;

struct BetterForA {
    address whosBetting;
    uint betAmount;
    // betAmount is in Wei
    string whichTeam;
    // team A is true, team B is false
}

BetterForA[] public bettersForA;

mapping (uint => address) whosBetsAreThese;
mapping (address => uint) countTheseBetters;

modifier hasntBet(uint _betAmount) {
    for (uint i = 0; i <= bettersForA.length; i++) {
        if (bettersForA[i].whosBetting == msg.sender) {
            updateBet(_betAmount, i);
        }
    }
    _;
}

function updateBet(uint _betAmount, uint _index) internal returns(uint) {
    bettersForA[_index].betAmount += _betAmount;
    return bettersForA[_index].betAmount;
}

function iBetA(uint _betAmount) public payable hasntBet(_betAmount) {
    require(_betAmount == msg.value);
    address _better = msg.sender;
    _betAmount = msg.value;

    uint id = bettersForA.push(BetterForA(_better, _betAmount, 'A')) - 1;
    whosBetsAreThese[id] = msg.sender;
    countTheseBetters[msg.sender] = id;
}

}

When I try to step through this function it ignores the modifier function but jumps from "uint id" in

uint id = bettersForA.push(BetterForA(_better, _betAmount, 'A')) - 1;

to the argument in the modifier

function iBetA(uint _betAmount) public payable hasntBet(_betAmount) {

before stepping through the hasntBet function

modifier hasntBet(uint _betAmount) {
    for (uint i = 0; i <= bettersForA.length; i++) {
        if (bettersForA[i].whosBetting == msg.sender) {
            updateBet(_betAmount, i);
        }
    }
    _;
}

and ultimately throws once it discovers there is no other entries in the array in which to check.

However when I remove the modifier function it runs as expected.


texts: How to set a custom gwei / gas price on uniswap/sdk Javascript using ethers.js module?

texts:
Im building an app to do trades on uniswap using ethers module. ive created contracts and imported the router and the factory contracts using this code:
const factory = new ethers.Contract(
  addresses.factory,
  ['event PairCreated(address indexed token0, address indexed token1, address pair, uint)'],
  account
);
const router = new ethers.Contract(
  addresses.router,
  [
    'function getAmountsOut(uint amountIn, address[] memory path) public view returns (uint[] memory amounts)',
    'function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts)'
  ],
  account
);

And now i pull a trade using swapExactETHForTokens function:
        const tx = await router.swapExactETHForTokens(
            amountOutMin // Slippage is set here too, if not wanted change to => amounts[1]
            [tokenIn, tokenOut],
            addresses.recipient,
            Date.now() + 1000 * 60  //1 minute expiry time for contract.
        );

My question is how do i implement custom gwei in my trade , there dont appeart to be an argument within uniswap trade functions for gwei at all.


texts: Can a miner "cheat" my lottery smart contract?

texts:
I developed a smart contract that you:

1) Send 1 ether to an address, the contract saves your address

2) After 5 people have sent one ether, the contract chooses one address at random and sends the 5 ethers to that address

I read here: What is the order and concurrency behavior of multiple calls to a contract in a single transaction?

that the miner decides the order of the transactions.

If more than 5 transactions are sent to the contract within the same block, can the miner game the system to enter his own transaction and execute the smart contract on the order he decides to win every time?

The winning address is chosen using

        random = uint(block.blockhash(block.number-1))%5 + 1;

I know a miner gets 5 ethers per each mined block + fees, so that's why I limited the inputs to 5 ethers total. The random function isn't that random, but the low payout (I thought) should make miners not care about gaming it. Here's the code of the function:

function () payable {
    require(msg.value == 1 ether);

    my_length +=1;

    gamblers[my_length] = msg.sender;

    if (my_length == 5) {
        // pick a random number between 1 and 5
        random = uint(block.blockhash(block.number-1))%5 + 1;
        gamblers[random].transfer(5 ether);
        my_length = 0;
    }

Thanks


texts:
For example in

Mapping(uint256 => address) public testForAddr;

It stores about 10,000,000 contents.

testForAddr[1] = 1
testForAddr[2] = 2
testForAddr[100] = 100
testForAddr[50100] = 6012
testForAddr[...] = ...
testForAddr[100000000] = 73159

If I get a key number now, such as testForAddr[7318], how can I quickly determine the value of the two keys closest to 7318 on the left and right?

e.g. I try like this:

for(uint256 ii = numberCount; ii < numberCount + 100000000; ii++)
{
     //numberCount == 100000000

     if(testForAddr[ii] != 0){
       //do something
       break;
     }
}

when I running this function, will be get this error:

Gas estimation failed


texts: web3js (v1.0.0-beta36) unable to use - Cannot find module 'buffer'

texts:
I included dist/web3.js (1.0.0-beta36) in my html file as below

<script type="text/javascript" src="./web3.js"></script>
<script type="text/javascript">
    var Web3 = require('web3');
    var web3 = new Web3();

    window.onload = function() {
        web3.setProvider(new web3.providers.HttpProvider("https://api.myetherwallet.com/eth"));
        var account = web3.version;
        var balance = web3.eth.blockNumber;
        balance = 0;
    };
</script>

When I launch the html with Firefox/Chrome it throws exception Error: Cannot find module 'buffer' then follow by Uncaught ReferenceError: require is not defined

If I downgrade the version of web3.js to v0.20.6, it functions ok. Did I missed something?


texts: How to get private key with web3 v0.2.x?

texts:
web3 version 1.x has the decrypt method, which decrypts a keystore v3 JSON.

By using it the following way, I can get the private key easily:

web3.eth.accounts.decrypt(keystoreJsonV3, password);

But how to get the private key with web3 version 0.2.x ?


texts: Adding default accounts with ETH in populus?

texts:
I'm thumbing through populus docs, and I don't see anything about adding additional default accounts preloaded with ETH into the test chain?

I see I can set defaultAccount and/or web3.eth.coinbase, but I'm not seeing where I can make up arbitrary accounts to be populated into the test chain.


texts: Most precise website to estimate gas price for volatile days

texts:
I am trying to understand which website is the best way to estimate the gasprice for volatile days. There are some sites but they do not work out so well on a volatile day like today.
I compared and tested today:

Metamask browser extension
Ethgasstation https://ethgasstation.info/(standard fee) which should execute <5min (which it does not)
ETHGastracker: https://etherscan.io/gasTracker

All have VERY different values. I think for actual transaction execution Ethgasstation is the worst. An transaction in typed in with the Estimated fee for standard (which should execute in under 5min): Is now pending for exactly 20min. For me it is no suprise since ETHGasstation is calculating the average over 1500 blocks (according to site) which is of course a useless number if you have a volatile day. Which site is best for volatile days according to practical experience? If no practical experience is there, for an approximation it would be a page that uses MUCH schorter timeframes like last block, last 2 blocks etc.

Thanks!


texts: Mintable tokens with some kind of identifier

texts:
I have the mintable token code working fine.  Now I would like to add the ability for the tokens to 'remember' when/why they were minted, such as,

0-100 group 1, 101-300 group 2, 301-1000 group 3, etc...

I had the idea of using another mapping, but once the tokens get transfered around, they need to remember what group they are in.

Thank You!


texts: Code:const web3 = new Web3(window.web3.currentProvider) Error: window.web3 is undefined

texts:
I am going to connect my contract with the website.However,there was something wrong with the web3? I'm not sure.

import Web3 from "web3";
const web3 = new Web3(window.web3.currentProvider);
const address = '0x9e3c32291496E8793xxxxxxxxxxxx'
const abi = [{"constant":true,"inputs":[],"name":"getBalance","outputs":[{"name":"","type":"uint256"}],"payable":.......];
const lottery = new web3.eth.Contract(abi, address);

used the functions of contract.

class App extends Component{
  constructor(props){
    super(props);
    this.state = {manager:'abc'};
  }
  async componentDidMount(){
      const ManAddress = await lottery.methods.getManager().call();
      console.log('********' + ManAddress);
      this.setState({manager:ManAddress});
  }
  render() {

the website consoler returned

TypeError: window.web3 is undefined


texts:
I have read many examples of payable functions, but I didn't understand any of them. Also, they talked about modifier in payable. My questions are:

  What exactly does payable() function do?
  Does this function take arguments?


texts:
I am practicing my Solidity skills and while I did expect to get an error, I did not expect this error

  TypeError: This type is only supported in the new experimental ABI
  encoder. Use "pragma experimental ABIEncoderV2;" to enable the
  feature. function getArray() public view returns (string[]) {

This is my code in Remix:

pragma solidity ^0.4.17;

contract Test {
    string[] public myArray;

    function Test() public {
        myArray.push("hola");
    }

    function getArray() public view returns (string[]) {
        return myArray;
    }
}

What gives here?

Is this because the standard ABI does not support dynamic nested arrays?


texts: How to sell product's access on a blockchain based marketplace?

texts: I want to sell a product's access (URL so that it can be downloaded) using smart contract on blockchain. I dont think I can add that URL on the product's specification contract as that would be visible to everybody that is looking at the contract. How can I sell the product so that everyone can review that product was sold (blockchain use-case) but nobody can access that access url but the buyer (not really blockchain use-case) ?


texts: Fatal:invalid genesis file:hex string has length 2, want 64 for common.hash

texts:
I'm new on the website. I'm following a french tutorial (yes i'm french) to create my own blockchain network. After installing all Geth stuff, creating my genesis file as following :

  {
   "nonce": "0x00",
   "difficulty": "0x1000",
   "mixHash": "0x00",
   "timestamp": "0x00",
   "parentHash": "0x00",
   "extraData": "0x00",
   "gasLimit": "0x1000000000"
   }

Then I tiped the following line :

  sudo geth --datadir ./noeud1 --networkid "100" init genesis.json

I have the following error :

  Fatal:invalid genesis file: hex string has length 2, want 64 for common.hash

Thank you for helping :)


texts:
I am testing my contract via the chai and truffle-assertions libraries from a JavaScript file and am testing if events return the correct values. I have an event called Message. In my function, the event is called twice consecutively but with a different id and message. The problem I have is that it gives me an error whenever I try to test for both events even though I checked it on remix and everything seems to work. Just testing for the events (truffleAssert.eventEmitted(result, 'Message');) works fine.

I can't give the events two different names as it will create a mess for the later development of my contracts and I'll end up with an enormous amount of events.

How can I get the tests to work? Is there a workaround this error?

Similar to the below (can't share my actual code though):

event Message(address id, bytes16 message);

function messages() public {
emit Message(0x1fe..., 'Almost there);
emit Message(0x0, 'Congratulations');
}

And my test file looks pretty much like this:

const Contract = artifacts.require('./Contract.sol')
const assert = require("chai").assert;
const truffleAssert = require('truffle-assertions');

contract('Contract', function(accounts) {
  let contractInst;
  let owner = accounts[0];
  let user1 = accounts[1];
  let user2 = accounts[2];

  before('getting instance before all Test Cases', async function(){
    contractInst = await Contract.new({from: owner});

  })

it("should check that the correct events are returned", async () => {
  let result = await contractInst.messages();

    truffleAssert.eventEmitted(result, 'Message', (ev) => {
      assert.equal(ev.id, user1, 'Correct id was returned');
      assert.equal(web3.toUtf8(ev.message), "Almost there", 'Correct message was returned.');
      return true;
    }, 'Contract should return the correct message.');

    truffleAssert.eventEmitted(result, 'Message', (ev) => {
      assert.equal(ev.id, user2, 'Correct id was returned');
      assert.equal(web3.toUtf8(ev.message), "Congratulations", 'Correct message was returned.');
      return true;
    }, 'Contract should return the correct message.');

})

})

The latest error message I am getting is that I am expecting the event to return the 0x1fe... address but instead it returns the 0x0 address so it looks like it's only looking at the return of the latest event. At the same time, even if I input the 0x0 address for both events it still returns an error message.

Thanks!


texts:
I'm a newbie to smart contract development, and I'm looking to order strings using solidity, I don't care that much what kind of ordering method (alphabetical for example) is used, I just want it to be deterministic and performant. I found out how to determine if two strings are the same when I searched for comparing two strings, but this is half what I want. If someone can give a clue on this, and also explain briefly to me why is string manipulation in solidity so unpractical, I'm sure there is a technical reason that I don't understand.
Here is what I have done so far:
function addStrings(string calldata _valueZero, string calldata _valueOne) public {
    bytes memory byteValueZero = bytes(_valueZero);
    bytes memory byteValueOne = bytes(_valueOne);

    if (byteValueZero > byteValueOne) {

    } else if (byteValueZero < byteValueOne) {

    } else {
        revert("You must enter two different values");
    }
}


texts: Is it impossible to use an array of strings as the argument to solidity function?

texts:
If I try to define a function using an array of strings as an argument, solc gives me the following error:

Error: Internal type is not allowed for public or external functions.
    function test(string[] x){}
                  ^--------^

This works fine:

function test(int[] x){}

And so does this:

function  test(string[] x) private {}

Am I missing something obvious?


texts: LoadCredentials function returns file not found exception

texts:
I am using the following code to deploy my contract:

@RequestMapping("/")
public String index() throws Exception {
    Web3j web3j = Web3j.build(new HttpService("https://rinkeby.infura.io/v3/2a42af3ce74e407cae9e20a7e7001ddb"));

    String walletId = "97a0987c270cd6cfa77972b83026eb56524857c5";
    String walletSource = "~/testnet-keystore/UTC--2018-09-26T00-58-36.238000000Z--" + walletId + ".json";
    Credentials credentials = WalletUtils.loadCredentials("admin1234", walletSource);

    ProofOfExistence contract = ProofOfExistence.deploy(web3j, credentials, Contract.GAS_PRICE, Contract.GAS_LIMIT).send();;
       String contractAddress = contract.getContractAddress();
       return "Contract is deployed at address: " + contractAddress;
}

But i am getting this error:
"java.io.FileNotFoundException: ~/testnet-keystore/UTC--2018-09-26T00-58-36.238000000Z--97a0987c270cd6cfa77972b83026eb56524857c5.json"

Can anyone tell me what am i doing wrong??


texts: Getting no space left on device while running geth --datadir ./datadir console

texts:
I am following this tutorial and while running below command.

geth --datadir ./datadir console

It ran for 15 hours and then returned below error.

  INFO [08-31|09:54:13.343] Imported new state entries
  count=2111 elapsed=13.073ms  processed=21254438 pending=5885  retry=6
  duplicate=393098 unexpected=939711

  CRIT [08-31|09:54:14.764] Failed to store last header's hash       err="write
  /home/ubuntu/medium-article/datadir/datadir/geth/chaindata/388142.log:
  no space left on device"

From the error log its clear this is memory issue but When i check the free memory using df -h the output is given below.

Filesystem      Size  Used Avail Use% Mounted on
udev             32G  4.0K   32G   1% /dev
tmpfs           6.3G  932K  6.3G   1% /run
/dev/sda1        55G   52G     0 100% /
none            4.0K     0  4.0K   0% /sys/fs/cgroup
none            5.0M     0  5.0M   0% /run/lock
none             32G     0   32G   0% /run/shm
none            100M     0  100M   0% /run/user

Could you please give me some hint where i am going wrong?


texts: how to make geth light node connect to local full node

texts: In my computer i have 1 full node, my full node is running using: geth --syncmode full --ws --wsport 8546. Is there anyway to create a light node to connect to that full node on the same local network manually?


texts: How to access variables defined in struct using 'Truffle'?

texts:
This is the sample contract given :-

 contract User {

             string public userName;
             mapping(address => Service) public services;

             struct Service {
                   bool active;
                   uint lastUpdate;
                   uint256 debt;
            }

            function User(string _name) {
                   userName=_name;
            }

          function registerToProvider(address _providerAddress) {
               services[_providerAddress]=Service({
                        active:true,
                        lastUpdate:now,
                        debt:0
               });

          }

          function setDebt(uint256 _debt) {
                   if(services[msg.sender].active){
                         services[msg.sender].lastUpdate=now;
                         services[msg.sender].debt=_debt;
                   }
                  else {
                        throw;
                  }

         }
         function payToProvider(address _providerAddress) {

              if(!_providerAddress.send(services[_providerAddress].debt)){
                     throw;
              }

       }
       function unsubscribe(address _providerAddress){
            if(services[_providerAddress].debt== 0){
                    services[_providerAddress].active=false;
           }else {
                     throw;
           }

       }

   }

I have to access the variables defined in struct using truffle.
I have deployed this contract using this command

     var user=User.deployed()

I have tried to access the struct values using this command.

       user.Service[active].call().then(console.log)

But it returns error.How can i check the values in Service structure.


texts: Can I use Web3.js to deploy and access smart contracts with a local TestRPC client?

texts:
I am at the point where I have migrated my smart contract to a local copy of the TestRPC test client.

1) Using a Node.JS app running on the same PC as the TestRPC test client, can I use the deploy() function to deploy a new instance of my smart contract to the locally running TestRPC client?  Or is that only possible with a test net like Rinkeby, etc. or the Ethereum main net as the deploy target?

2) Same question but for accessing smart contracts via the Web3.js library.  Can I use that library to interact with the smart contract instance running in the local TestRPC client from a Node.js app running on the same pC.

If anyone has any links to any good samples that shows how to migrate/deploy a smart contract and access the smart contract's view functions from a Node.JS app using the Web3.js library, please share.


texts: How to check tokenBalance of some other contract in my contract

texts:
I am looking to check token balance of some other contract into my own contract to see how many tokens of that contract are owned by my user.

Is this possible? If yes how to achieve it?

I tried this way

contract ERC20Interface {
function balanceOf(address whom) view public returns (uint);
}


texts: How to Submit 0.4.10 Sol version Contracts to Etherscan for Verification

texts: I am trying to verify a Solidity Contract I wrote using Remix written in Solidity version 0.4.10.The problem is that Etherscan wont allow me to select Solidity Version 0.4.10 for my Project.


texts: Is this a good ethereum mining rig (with rx 580 4G sapphire nitro+)?

texts:
I'm planning to build a mining rig in the business where i work (electricity is not a problem, we have a flat contract).

So...

My configuration would be:

6 x RX 580 4G Sapphire Nitro+

power risers

EVGA 220-P2-1600W PSU

Intel Celeron G3900

AsRock h110 pro btc+

A case

Will this configuration work out of the box?

Especially i would like to know if i can use only 8 pin on the RX 580 without using the additional 6 pin


texts:
I am trying to follow the truffle pet shop tutorial. But failed to connect metamask with ganache-cli
I ran ganache-cli in the console and changed the rpc url to http://127.0.0.1:8545
But the addresses are still not loading and neither the balance is going up.


texts:
When I interact with my deployed smart contract (Ropsten testnet) on Chrome I sometimes face the following situation :

I call my method which is an approval of my contract

After confirming I get this second window which should not exist :

I can't click on "reject" or "confirm", the window is stuck.

I had this issue twice in 3 days. To fix it I had each time to reinstall Metamask. Then, all was working well again.
Any idea what's going on ?


texts:
I cannot call the settoken function
transact to TRUST.settoken errored: VM error: invalid opcode. invalid opcode The execution might have thrown. Debug the transaction to get more information.
pragma solidity ^0.6.0;
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/IERC20.sol";
import"https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/math/SafeMath.sol";

contract TRUST is Ownable{
    using SafeMath for uint;
    uint public free;

    mapping (address => mapping(address => data[])) public _data;
    mapping (address => address[]) public fromaddr ;

    struct data{
        uint64 startTime;
        uint64 intervals;
        uint256 onceamount;
        uint256 alltoken;
        address ercaddr;
    }

    function _FREE (uint _free)public onlyOwner{
        free = _free;
    }

   function tokennum(address _from, address _to, address _tokenaddress)private view returns(uint e, uint ee){
      if(_data[_from][_to].length != 0){
        for(uint8 i; i <= _data[_from][_to].length; i++){
           if (_data[_from][_to][i].ercaddr == _tokenaddress){
               e++;
               ee = i;
           }
        }
      }
   }

    function settoken (address token ,address to ,uint64 startTime ,uint64 intervals ,uint256 onceamount ,uint256 alltoken)public payable{
        require (msg.value == free ,"free err");
        require(IERC20(token).transferFrom(msg.sender ,address(this) ,alltoken),"etc");
        require (uint(to) *uint(token) *startTime *onceamount *alltoken != 0 ,"input");
        uint e;
        uint ee;
        (e,ee) = tokennum(msg.sender , to , token);
        require(_data[msg.sender][to][ee].alltoken == 0);
        if (ee == 0){
            _data[msg.sender][to].push(data(startTime ,intervals ,onceamount ,alltoken ,token));
        }else {
            _data[msg.sender][to][ee] = data(startTime ,intervals ,onceamount ,alltoken ,token);
        }
        IERC20(token).transferFrom(msg.sender ,address(this) ,alltoken);
    }

}


texts: Creating a system with multiple blockchains where they can interact with one another?

texts: I'm currently trying to create a sort of proof of concept where I would like to create a system of blockchains for individual accounts to track their balances. The idea is to have a snapshot of their balance history in each block. Sort of like having each block represent the balance of the account before a transaction goes through. I would also like to have another blockchain for the transactions and would like to embed that transaction block into one of the blocks in the account blockchain or at least embed a reference to it. That way I could tell which transaction effected the account balance. I'm not sure if this is even possible through blockchains or even through smart contracts? The reason for not doing it in a database is to make sure we I can get a full history of the balances of each account and for security. I would like some directions on how to go about creating this if its possible.


texts: What are the main differences from Python and Serpent?

texts: Serpent looks quite similar to Python.  What behaviors or syntax would be on your list to warn other Serpent developers about?


texts:
Trying to send ether to multiple addresses. For the first address the transaction succeeded but for the rest of the addresses it is showing "transaction underpriced". Below is the code attached. I have tried changing the gas price, but that didn't work.

var ad = ['0x66622d1E25cca28454c2e2b4726c05b27B094f68', '0x2F55E7E8Af52dC91715670e579c64A2a84d21A50', '0xd2a56Eb440725BAf29eE1cfA7899c12Ef1BC642D'];

function newfunction() {
    for (var i = 0; i < ad.length; i++) {
        sendRaw(rawTx);
        var rawTx = {
            nonce: web3.toHex(web3.eth.getTransactionCount(address)),
            gasLimit: web3.toHex(21000),
            gasPrice: web3.eth.gasPrice.toNumber() * 1.40,
            to: ad[i],
            value: web3.toHex(web3.toBigNumber(10000000000000000))
        };
    }
}

Attached is the error


texts: What are limitations of Event arguments?

texts:
Are there any limitation on the amount of arguments that can be send in an event?

I have a function in which I want to trigger event that has 12 arguments of which 6 arguments are arrays. I get Stack too deep, try using less variables. Without the event the function works normally.

I am guessing event arguments have some limitations or count towards max arguments in a solidity function but I cannot find any documentation around it.

Can anyone clarify this?


texts: Why is there a discrepancy between etherhub.io and gastracker.io?

texts: I traded for Ether Classic (ETC) using ShapeShift and my Coinomi Wallet.  The amount I received shows in both my Coinomi Wallet and on gastracker.io, but etherhub.io, etherscan.io, and ethplorer.io all show zero balance.  Can someone explain that?  Thanks.


texts: Migrating/Forking an ERC223 Token to a New Contract

texts:
I am coding a token that depends on referencing a current exchange rates to calculate the fee required to transfer a token. Should this reference some day break down, I would need to make a new updated contract to continue the use of the token as my fallback currently is to cease transacting.

Is there any ideal way to do this?

I've referenced this thread: https://www.reddit.com/r/ethereum/comments/5rcp9m/what_happens_when_you_try_to_fork_an_ethereum/


texts: Mobile android app that can import a Metamask private key?

texts: I'm having some issues sending out from metamask and getting failed transactions. I think maybe I should use another app on android if possible. What android wallet apps can import a Metamask private key?


texts: Could address reuse leak your mnemonic seed?

texts:
According to this question and its answer Is it safe to reuse Ether addresses? it is theoretically possible to leak your private key by reusing your ETH address.

Since my ETH address is derived from my mnemonic seed, would this also possibly leak my mnemonic seed and thus potentially give access to my other funds (BTC, Dash etc.)?

If no, is there any threat to other generated ETH addresses from this seed?


texts:
I tried to bit on an ens registry with the following command:

var bid = ethRegistrar.shaBid(web3.sha3('mydomain.eth'), eth.accounts[0], web3.toWei(1, 'ether'), web3.sha3('secret'));

after I placed the bid I realized that the name should be 'mydomain' and not 'mydomain.eth'

Is there any chance to reclaim my ETH and bid again with the correct name?


texts: Member "call" not found or not visible after argument-dependent lookup


texts: Can't connect to local rinkeby node from web3.js

texts:
I'm developing a Dapp using truffle and I need to connect to a contract that I uploaded on rinkeby using truffle migrate --network rinkeby. Problem is that I'm unable to connect to the rinkeby network from the web3 interface. I run a rinkeby local node using

geth --rinkeby --rpc --rpcapi db,eth,net,web3,personal --rpcport 8545 --rpcaddr localhost --rpccorsdomain "*" --unlock="0x4A1b47b0b119AFD421ec4E3b5B54D8EF5141b59c"

The front-end code is

if (typeof web3 !== 'undefined'){
        web3 = new Web3(web3.currentProvider);
    }else{
        web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
  }

But the code always slaps me with

Error: Provider not set or invalid.

How can I resolve this issue and how to create a new contract instance from contract abi?


texts: How do I make an efficient lookup table?

texts:
I need a 110-length lookup table that stores numbers from 1 to 20.

I think the solution might be to move the instruction pointer forward by the index, and then return. Is something like this possible? For example:

JumpForward index
return 1
return 2
return 2
etc...

Following are what I've tried so far, compiling with optimizations on:

A table in memory - 3086 gas

function lookup(uint256 index) private pure returns (uint256) {

    uint8[110] memory bellCurveTable = [
         1,
         2, 2,
         3, 3, 3,
         4, 4, 4, 4,
         5, 5, 5, 5, 5,
         6, 6, 6, 6, 6, 6,
         7, 7, 7, 7, 7, 7, 7,
         8, 8, 8, 8, 8, 8, 8, 8,
         9, 9, 9, 9, 9, 9, 9, 9, 9,
        10,10,10,10,10,10,10,10,10,10,
        11,11,11,11,11,11,11,11,11,11,
        12,12,12,12,12,12,12,12,12,
        13,13,13,13,13,13,13,13,
        14,14,14,14,14,14,14,
        15,15,15,15,15,15,
        16,16,16,16,16,
        17,17,17,17,
        18,18,18,
        19,19,
        20
    ];

    return bellCurveTable[index];
}

An if-else chain - 45 to 449 gas

function lookup(uint256 index) private pure returns (uint256) {
    if      (index <=   0) return  0;
    else if (index <=   2) return  1;
    else if (index <=   5) return  2;
    else if (index <=   9) return  3;
    else if (index <=  14) return  4;
    else if (index <=  20) return  5;
    else if (index <=  27) return  6;
    else if (index <=  35) return  7;
    else if (index <=  44) return  8;
    else if (index <=  54) return  9;
    else if (index <=  65) return 10;
    else if (index <=  76) return 11;
    else if (index <=  86) return 12;
    else if (index <=  95) return 13;
    else if (index <= 103) return 14;
    else if (index <= 110) return 15;
    else if (index <= 116) return 16;
    else if (index <= 121) return 17;
    else if (index <= 125) return 18;
    else if (index <= 128) return 19;
    else                   return 20;
}

An assembly switch statement - 94 to 2445 gas (estimated)

function lookup(uint256 index) private pure returns (uint256 stat) {
    assembly {
        switch index
        case   0 { stat :=  0 }
        case   1 { stat :=  1 }
        case   2 { stat :=  1 }
        case   3 { stat :=  2 }
        case   4 { stat :=  2 }
        case   5 { stat :=  2 }
        case   6 { stat :=  3 }
        case   7 { stat :=  3 }
        case   8 { stat :=  3 }
        case   9 { stat :=  3 }
        case  10 { stat :=  4 }
        case  11 { stat :=  4 }
        case  12 { stat :=  4 }
        case  13 { stat :=  4 }
        case  14 { stat :=  4 }
        case  15 { stat :=  5 }
        case  16 { stat :=  5 }
        case  17 { stat :=  5 }
        case  18 { stat :=  5 }
        case  19 { stat :=  5 }
        // etc...
        default  { stat := 20 }
    }
}


texts:
I unfortunately need the Ethereum Alarm Clock, but everything concerning this is either deprecated or unclear, could someone write very simple example? I've been fighting with that for a week and it's a dead end.

Cheers!


texts: Have someone tried to implement a private ethereum network based on BaaS of Microsoft & azure servers or some other companies?

texts:
I'm creating/implementing a private ethereum network for a group of friends to "play with" the blockchain, develop dapps on top of it.

during my google searches, I found the "blockchain as a service" offer from Microsoft that's basically presented as the AWS of the blockchain with some ready to use environment.

can I get some feedback on that? what are your "go-to" if you wanted to create a private ethereum blockchain?

What is the minimum required hardware to run a private network (how many servers? minimum CPU, RAM, Hard disk etc etc)?

EDIT:
to make things clear : I want to create a private ethereum network, implement/develop a dapp on top of that ethereum private ecosystem and let people/clients access to it and use it.

I'm asking about the BaaS and the minimum hardware requirement because I want the network and the platform to be as much professional as possible and as much stable as possible


texts:
I'm trying to create a smart contract that would send funds from one wallet to another by taking values from an array that I fill. But it does not send values unless I specify them in msg.value. How can I send money by property id without user participation?
P.s: in private network

pragma solidity ^0.4.18;

contract property {

uint256 cad_number;
address customer;

struct propertyInfo{
    address Owneradress;
    uint256 cad_number;
    string location;
    uint32 cost;
    bool housing_status;
}

mapping(uint256 => propertyInfo) propertys;
mapping (address => uint) public balances;

    function Create_Property(address Owneradress,
                             string memory location,
                             uint32 cost,
                             bool housing_status
                            ) public{
        propertyInfo storage NewProperty = propertys[cad_number];
        NewProperty.Owneradress = address(Owneradress);
        NewProperty.location = location;
        NewProperty.cost = cost;
        NewProperty.cad_number = cad_number;
        NewProperty.housing_status = housing_status;
        cad_number++;
    }

    function Listing_property(uint256 prop_id) public view returns (
                                                                     address,
                                                                     string memory,
                                                                     uint256,
                                                                     uint32,
                                                                     bool
                                                                   ){
        propertyInfo storage s = propertys[prop_id];
        return(s.Owneradress, s.location, s.cad_number, s.cost, s.housing_status);
    }

    function transaction_to_contract(uint256 _id) public payable {
        propertyInfo storage s = propertys[_id];
        s.Owneradress.transfer(s.cost);
        balances[s.Owneradress] += s.cost;
    }
}


texts:
Im a little bit confused about how smart contracts work. Let's say there was a contract that users could send ether to in order to play a game. This contract would store the ether sent to it, run the game logic, and handle the funds accordingly.

If the game is finished (let's say each round in the game was active for x amount of hours and x hours have passed), can this smart contract be re-used? Or does a new instance of it need to be deployed again in order for a new round to occur. If it is reused, does it need to be programmed to clear up any old data from the previous round?


texts: Full node sync only preserve the last 128 history states

texts:
While researching on the different sync modes and their behaviors, I learned that geth full sync will replay all transactions from the genesis and preserve all history states, while fast sync will only download block data without statedb until around 100 blocks before the latest block head, and then perform as a full node.

I decided to verify these behaviors in this way:

I started a private network, and mined 2000 blocks with no transactions (but the balance of the miner should keep increasing because of the coinbase transactions).
Then I started other geth instances with different dirs and ports. Connected them to the private network node in full and fast sync.

Here's what I discovered:

In full sync geth instance, I'm able to query the state(by calling eth.getBalance(eth.accounts[0], <blockNumber>)) only for the last 128 blocks.
In fast sync geth instance, I'm able to query the state only for the last 64 blocks.

In both cases, querying states from older blocks result in a missing trie node error. Digging deeper into the code, I found that those trie nodes (state roots of old blocks) are simply not saved in the underlying leveldb.

The behaviors did not match what I expected. I'm wondering if there's anything wrong in my experiment setting. Are there default state trie pruning that I'm not aware of? I'm using the latest geth 1.8. Any pointers are welcomed.


texts: solc-v0.6.0: TypeError: Operator - not compatible with types tuple() and int_const 1

texts:
I am having this error on solc version 0.6.0.

Basically I am returning length of the list and subtract 1 from it, where that value will be assigned to an uint variable.

In general this command used to return the length of the list after the push:

uint length = list.push(Struct({val: value}))

TypeError: Operator - not compatible with types tuple() and int_const 1
uint32 value = uint32(list.push(Interval({endpoint: startTime})) - 1);

I was not getting this error or solc-v0.5.*.
I feel like tuples does not return their length any more.

[Q] How could I fix this error?


texts: Decoding transaction input data with web3j (Java)

texts:
My use case is the following:
I would like to have a daemon monitoring how users are interacting with my smart contract.
The way I see it is to look at incoming blocks and try to decode input data with a to address corresponding to my contract.
I was unable to find in web3J a way to decode data.

1- Is there any way with web3J to decode the data ?

2- Have I any other way to achieve my goal than decode the input data ?
Events seems to me as an hard choice as I will not be able to easily monitor every things. And this methods cannot apply to smart contract that I don't own.

Thanks for the help.


texts: What are the steps of deploying a smart contract to the blockchain?

texts:
Are the above steps correct for deploying a smart contract to the blockchain:

A node creates a smart contract
The smart contract is converted to byte code
The node creates a block out of the byte code
The node adds it to his local blockchain
The node broadcasts the block to other validators/miners
The miners verify the block and add it to their local blockchain
After some time the longest chain rule is executed and the longest
chain is written to all miner nodes (consensus)

The main questions I have is, are smart contracts stored inside blocks in a blockchain and do smart contract require verification by all nodes in a blockchain network?

Your help and support is much appreciated
Thanks


texts: How would you create a smart contract that allows for a commission?

texts: Let's say you were building a marketplace and you wanted to take some type of commission for allowing a user to sell a thing on your marketplace....how exactly does that work? Is there some type of template you can use that allows a person to pay you a commission, but then receive the payment for the sale of their item?


texts:
is there direct way to make a contract on either the main or test net to communicate with a contract on the other net?

This could be generalized as asking if a contract on private chain can communicate with another one contracts.

Thanks.


texts: Calling contract function via web3.eth.sendTransaction doesnt work

texts:
Im learning how Blockchains work and created a private Blockchain to test some things. I deployed the following contract:

contract Greeter
{
    address creator;
    string greeting;

    function Greeter(string _greeting) public
    {
        creator = msg.sender;
        greeting = _greeting;
    }

    function greet() constant returns (string)
    {
        return greeting;
    }

    function getBlockNumber() constant returns (uint)
    {
        return block.number;
    }

    function setGreeting(string _newgreeting)
    {
        greeting = _newgreeting;
    }

    function kill()
    {
        if (msg.sender == creator)
            suicide(creator);
    }

}

Now I tried different methods to call the setter function
I got the instance with using contract address and abi and called

instance.setGreeting.sendTransaction(...)

This one worked and with instance.greet() I got the new greeting.
But then I tried an example from this page https://github.com/ethereumbook/ethereumbook/blob/develop/transactions.asciidoc#invocation
and called

web3.eth.sendTransaction({from: eth.coinbase, to: contract_address, data: "0x4136862e000000000000000000000000000000000000000000004d794e65774772656574"})

where the data is created of the first 4 bytes of the Keccak256 hash of the prototype function setGreeting(string) and the String "MyNewGreet" encoded to Hex and padded to 32 bytes. The transaction is mined but instance.greet() still return the old greeting


texts: How to connect with Metamask and Smart contract?

texts: I am ready with my frontend design. I have only 3 files HTML, CSS, and JAVASCRIPT. So, I didn't create any project or DAPP to have other files. Now next step is to connect with metamask and smart contract for payment. I am not getting exactly what I need to do now. Do I need node js files? If yes, then how? or any other files? How to connect with metamask? I searched for many codes but didn't get anything. Can somebody explain to me?


texts: geth keeps failing to sync past a certain point

texts:
January is almost done, and so my first test of Ethereum. The first 2 weeks I was doing pool mining, and I must say it worked really easy. About a week ago I decided to do the Solo mining thing, and I think I might have gained a couple of gray hairs since then. My problem, I can't get geth node to sync past a point.

My scrapyard rig:

Intel(R) Core(TM)2 Quad CPU Q6600
2 x 2GB DDR 800 MHz RAM
SSD HDD
2 x Nvidia 1070
Ubuntu 16

My setup

geth as per the official instruction with apt-get
ethminer as per the official instruction with source compilation

I start geth in a screen window with

 geth --cache=256 --rpc --rpccorsdomain localhost console 2>&1 | tee /tmp/eth.log

I have gotten as far as ~80% once, but it then just starts from 0 again.

Once it hit a fork..

a couple of time it got very slow around 20~30 %, I stop it. Start new

a couple of time it just jumps back to way under 50%, I stop it. Start new

I have now tried about 5 times to start from 0, by deleting the folder $HOME/.ethereum and more recently only $HOME/.ethereum/geth/chaindata

I have since started a backup folder of the chaindata, as it's really big.

Attempt 6 is currently at 25 %.. (The javascript)

Is there something I am missing?


texts:
Keystore file is not created when I am creating a new Ethereum wallet account using nethereum and UWP. Also the newly created account is not in the private net.

The new account is created using the following code:

   var privateKey = txtPassword.Text.ToHexUTF8();
   var account = new Nethereum.Accounts.Account(privateKey);


texts:
Date Dec 16th 2017.

Based on the block stats of the few last days, block gas limit being around 8 million, block time little short of 15 sec and the block used gas / gas limit ratio approaching 95 %, the current theoretical transaction cap appears to be around one million (1.0 M) transactions per day.

Apparently the block gas limit was raised somewhere around Dec 4th as the block time and size jerked upwards and block count downwards. The most noteworthy change was the ratio of uncles, which jumped from avg. 12.2% to avg. 26.1% (Byzantium era since Oct 16th). If I've understood correctly, uncles are a nuisance to those whose transactions ended in them, and detrimental to the efficiency as they have to be reprocessed?

We're probably crossing that one million txn/day milestone as I write this, or at least during the very few next days.

Questions:

To make space for more transactions, the block gas limit should be raised again?

This will either increase the block time, or, if the block time needs to stay at 15 secs, the difficulty must be lowered?

Both longer block time and lower difficulty lead to more uncles?

More uncles deteriorate the efficiency and hence the performance of the blockchain?

Longer block time / lower difficulty also exposes the chain to attacks?

How sensitive is the system for additional increases to block gas limit, and is there any other very short term measures to accommodate the exponentially increasing transaction load?


texts: Is it possible to download the Ethereum state trie and state database on their own?

texts:
I want to download a more or less recent version of the Ethereum state trie and state database, i.e. some version from within the last 1000 or so blocks. I know that I could set up a full node and let it sync completely, but that takes quite some time (even in fast mode) and requires an SSD in order for syncing to finish. Also, I am not interested in block headers at all, but only the state trie and state database.

Since Geth's --syncmode fast option "downloads the transaction receipts along the blocks, and pulls an entire recent state database" (see here), is there a way to only get that recent snapshot state database without downloading everything else?


texts: Vanity Contract Address with Solidity Deployment?

texts:
I would like for my contracts to have vanity addresses, more specifically to begin with the word "face" such as "0xface...".

I have the following code to deploy a Token, and my problem is deploying it to a Vanity address, with a Vanity address contract as well, instead of a random one.

Here's where I believe it would be done:

contract SimpleToken is StandardToken {

  string public constant name = "FACETOKE";
  string public constant symbol = "FACE";
  uint8 public constant decimals = 18;

  uint256 public constant INITIAL_SUPPLY = 1000000*10**18; // 1 million Face tokens

  function SimpleToken() {
    totalSupply = INITIAL_SUPPLY;
    balances[msg.sender] = INITIAL_SUPPLY;
  }

}

And here is my full current code:
https://gist.githubusercontent.com/anonymous/caeff72acbaa144eff23bfbc84912b33/raw/f1fbc2778d9595ebaac6bf5715ef1a6024dae33d/FaceToken.sol


texts: Can chaindata be split across two (or more) locations?

texts:
With the size of full nodes rapidly growing, I'm looking for a way to split my chaindata across multiple hard drives. I have one internal 1TB SSD capable of syncing the chain, and then an internal HDD and an external SSD, each 1TB. My internal drive is rapidly filling up, so I'm interested in porting some of chaindata onto one of the other drives.
I'm using Geth (on Linux), though I would prefer this to be a client-agnostic question in case someone else has the same question while using a different client.
Thanks!


texts: Does all the gas needed to use EVM go to miners?

texts:
I'm trying to understand the financial model of Ethereum and despite all the reading on gas and how transaction cost is calculated still it is ont clear to me whether all gas needed to use EVM goes to miners or it is credited to the organization that then credits miners according to their activity?
This is the most important part of my question but in the light of understanding the financial model I would appreciate any link that explains how Ethereum makes money to sustain it's operation.

Thanks!


texts: Private Network - Ethereum Peers not connecting to LXC Containers nodes

texts:
We have 4 Computers with LXC containers installed. We have 4 geth instances running on host PCs and 4 geth instances running on LXC containers. My issue is that the nodes on host PCs and LXC containers are not able to connect each other and form peer connections.

This is the output of ifconfig on one of the PC and the IP of container is 10.0.3.84:

Initially, all the geth instances were running on port 30303 and we tried admin.addPeer(enode://XXXX@<ip-of-container>:30303) on host node to connect. But failed.

Then we ran host geth instances and Container geth instances on different ports. But still we were unable to make a connection.

Then we enabled port forwarding on the host PC using
iptables -t nat -A PREROUTING -p udp -i eth0 --dport 587 -j DNAT --to-destination 10.0.3.84:587

and then ran the nodes on different ports (host node on port 30303 and container node on port 587). Then on the host node we tried admin.addPeer(enode://XXXX@<ip-of-the-host>:587) but it failed again.

I will be obliged to any solution provided.


texts:
I use react and web3 to interact with metamask.
Until yesterday every thing was fine. but, today some of the transaction results are not returning.
I use this code to load web3
let web3
if (window.ethereum) {
  web3 = new Web3(window.ethereum)
  await window.ethereum.enable();
  this.setState({web3: web3})
}
else {
  window.alert('Non-Ethereum browser detected. You should consider trying MetaMask!')
}

when I, want to use send().on('receipt')... its not returning anything.
but send().on(transactionHash)works fine
I have no clue why would receipt suddenly stops to work.
here is the code
contractInstance.methods.transferOwnership(newOwner).send({from:
accounts[0]}).on('receipt', function(receipt){
        console.log("events of transfer ownership" , receipt.events)
     })

I mean the function works fine and the ownership transfers, but the receipt is not working at all


texts: What are the challenges involved moving Ethereum from POW to POS?

texts: I'm aware of the idea to roll out the POS protocol by using a hybrid model of POS/POW. What are the challenges of such a change? This hybrid model would make mixed adoption(for legacy users and new alike) easier but what are the trade-offs of this?


texts: Am I hashing the data in the file itself, or just the reference?

texts:
I am attempting to create an app where I upload a file to a website and then I submit a hash of that file onto Ethereum. I am unsure whether I am hashing the actual file below or just the reference to the file.

Any suggestions for the script below?

const input = document.querySelector('input');

input.addEventListener('input', e => {
    e.preventDefault();

    const hash = web3.sha3(e.target.value);

});

Any help would be greatly appreciated.


texts: How can I search the latest transaction of specific account in a ERC20 contract?

texts:
Here is the TUSD smart ERC20 contract, if I have a transaction hash, how can search the transaction history with this transaction hash?

right now the only way I can think is to get the whole history, but that doesn't seem to be effecient as shown

contractAddress = "0x00.."
web3.eth.filter({
address: contractAddress
from: 1,
to: 'latest'
}).get(function (err, result) {
// callback code here
})


texts: truffle migrate fails with Network state unknown, Error: account is locked

texts:
I'm trying to run the truffle demo on the ethereum testnet but truffle migrate fails with "Error encountered, bailing. Network state unknown. Review successful transactions manually. Error: account is locked"

I'm running test net using the command

geth --testnet --rpc --rpcapi db,eth,net,web3,personal --cache=1024  --rpcport 8545 --rpcaddr 127.0.0.1 --rpccorsdomain "*" --bootnodes "enode://20c9ad97c081d63397d7b685a412227a40e23c8bdc6688c6f37e97cfbc22d2b4d1db1510d8f61e6a8866ad7f0e17c02b14182d37ea7c3c8b9c2683aeb6b733a1@52.169.14.227:30303,enode://6ce05930c72abc632c58e2e4324f7c7ea478cec0ed4fa2528982cf34483094e9cbc9216e7aa349691242576d552a2a56aaeae426c5303ded677ce455ba1acd9d@13.84.180.240:30303"

and then in another tab:

truffle console
web3.personal.newAccount('samplepassword')
web3.personal.unlockAccount(account hash, 'samplepassword', 15000)
migrate

I've tried using both testrpc and ethereum testnet, and have gotten the same account locked error both times.


texts: Smart Contract Deployment Stays in Pending State

texts: Pretty straight-forward problem. I'm trying to deploy a smart contract token using Mist (not the browser). When I click deploy, it asks me to confirm, tells me the gas it'll use (maybe that's too low? Currently it's at 8) and then I confirm and it just stays in pending state. I've tried to deploy it 3 times now with increasing gas. What could be the problem? The current max amount of ETH to spend is .016, that's quite a bit and it still isn't confirming.


texts: Should i move my erc20 token from ropsten to main network?

texts:
I have just created token in ROPSTEN network, so Im confused now... Can I use my tokens in main ether network (sel, give, etc) or I just van play with them in test network and forget...?

Should i move my erc20 token to main network? to use my tokens as coins in regular ether network?


texts: How to convert byte array to bytes32 in solidity

texts:
I want to know the syntax to convert a byte array to bytes32 in solidity.

This is a follow up to the question- How to store Public Key in Ethereum contract?

I want to retrieve the PublicKey stored as byte array.

Kindly advise me know how this could be accomplished.

Thanks.


texts: What is the correct value to report for input data in this context?

texts:
On this transaction: https://etherscan.io/tx/0xae2630cdfbd0ca5292d272343c35dc8094365f2ecdc5c262c5639e79683f74dc, the input data is parsed and displayed as 'fund'.

This is both correct and incorrect.

It is incorrect because there is no function in the 'to' contract (singularDTVToken) called 'fund.'
(https://etherscan.io/address/0xaec2e87e0a235266d9c5adc9deb4b2e29b54d009#code).

But there is a function called 'fund' in a related contract, and the 4byte encoding for 'fund()' is 0xb60d4288, which is the value of the input data.
(Related contract is  called SNGLSCrowdFund: https://etherscan.io/address/0xbdf5c4f1c1a9d7335a6a68d9aa011d5f40cf5520#code.)

I think it's misleading to say that the input data resolves to 'fund' in this case. This suggests that a function called 'fund' was invoked on the contract, when in fact, it was not.

My question is this: Is it correct to report 'fund' in the context of a contract that has no 'fund' function. Wouldn't it be more accurate to indicate that the default function had actually been called? (And is it true that the default function would have been called in this case?)


texts: How Right to be forgotten can be applied with Dapps like Akasha?

texts: As Akasha decentralized social network is ready to launch, I wonder how rights like "Right to be forgotten" can work as the blockchain never forget ?


texts: GETH is always stuck after attempting to sync

texts:
I want to mine Ether and I've been trying to sync blockchains for days.

I've tried using geth --fast command and it always stuck as in the picture.

My computer is running 64 bit Windows 10 with geth 1.4.10 installed. I've also tried using geth --rpc but it gave me the same result. I'd guessed that it was because my ISP blocks P2P connection but after I try connecting via VPN nothing's changed.

I've already set my time synchronization to be with time.nist.gov as some soln I've found suggest.

Also I have trouble with MIST hang up on 'seeking peers' on startup without any progress.

What should I do to get this stuff done?


texts: C# - Convert Ethereum ABI Address To String (Solidity)

texts:
I'm new to Ethereum so please excuse my ignorance. Ethereum seems to have an ABI serialization protocol called Solidity. The spec is here:
https://github.com/ethereum/wiki/wiki/Ethereum-Contract-ABI

I'm looking for a way to encode and decode contracts in C#. Specifically, I want to take an array of bytes (byte[]) and convert it in to a human readable Ethereum address as a starting point.

Here are a couple of libraries that I've cloned, but after sifting through the code, it's not immediately apparent how to achieve what I am trying to do:

https://github.com/Nethereum/Nethereum

https://github.com/sense2k/Ethereum.NET

Can someone point me to an example of how to convert a byte array to a human readable Ethereum string address?


texts:
I am trying to implement deposit functionality in my contract in the sense whoever calls the function below needs to deposit some ether. For example:
Contract A calls the function below and again, Contract A needs to deposit some ether.
I can do this with the remix interface by passing "VALUE". But I want to pass this variable as an argument.
Here is what
event Deposit(address sender, uint amount, uint balance);

function deposit(uint testAmount) public payable {
    testAmount = msg.value; // GIVES ERROR
    emit Deposit(msg.sender, testAmount, address(this).balance);
}

function doWork(int job_id, uint amount) public payable{
   deposit(amount);
}


texts:
If smart contract code is visible to everyone, can't I just copy the entire contract code and make my own contract and deploy it on Blockchain.
So this way many duplicates will be present and one can easily copy the business idea of others.
How to prevent this?


texts:
Just trying to understand a bit about Optimistic Rollups. Was wondering where does the actual contract that uses ORs gets deployed? Is there a copy on both L1 and L2? I would assume yes, since how else a contract state could be validated?
Also, in which contract the Merkle Tree root is tracked? Is it the same contract to which you deposit/withdraw funds between L1 and L2?
Finally, who pays for calldata transactions?
Thanks!


texts:
What would be the safest way to combine my mining efforts across approximately 30 machines? Should I...

Have a separate accounts/wallet on each and consolidate my results frequently via script?
Use the same wallet and key across all devices?
Use some kind of pool? This seems inefficient for ETH.


texts:
The Design and issue your own cryptocurrency tutorial introduces registrar to create address aliases.

Is registrar a built-in contract reference?
Why does tab completion for r not suggest it?
Are there any other such contracts?

Thanks


texts: I tried to upgrade Geth to 1.4.6, now I get fatal error "Error starting protocol stack datadir already used"

texts:
I tried to upgrade Geth to 1.4.6, now I get this error, why and how can I fix it?

Fatal: Error starting protocol stack: datadir already used

OS: Ubuntu 15.10

Note: Chaindata is being symlinked to an external SD card, not sure if that is relevant


texts: Couldn't understand the logic behind code for mulitdeed payout contract

texts:
While searching on the web I came across this page the user has created multiple examples of solidity smart contract
On multiple payout deed smart contract I can't understand this line
duePayouts = duePayouts + paidPayouts > PAYOUTS ? PAYOUTS - paidPayouts : duePayouts;
This is the link to example
If you can please explain how that line works and what are those operators ':' and '?'
Thanks


texts: Is there any free crypto wallet api available

texts: Can anyone tell that is there any free crypto wallet api available which one can use in a project


texts: Creating Contract instances from contract methods

texts:
I've been working on the concept of building a MUD type game using Blockchain as the data storage.
Note - this is a private network - so ether cost is not really a huge issue for me.

Given a contract that looks like this:

contract EtherWorldStorage {
    /* Constructor */
    address owner;
    mapping (bytes32 => World) Gameworlds;

    mapping (bytes32 => uint) NamesIndex;
    World[] worldContracts;

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

    event WorldCreated(bytes32 indexed worldName, address indexed sender, address result );

    function createWorld(bytes32 name) returns (address a){
        if(NamesIndex[name] > 0x0){
            return 0x0;
        }
        World w = new World(name);
        NamesIndex[name] = worldContracts.length - 1;
        Gameworlds[name] = w;
        WorldCreated(name,msg.sender,w);
        return w;
    }

  function getWorldCount() returns (uint i){
        return worldContracts.length;
    }

    function destroyWorld(bytes32 world){

        World w = Gameworlds[world];
        w.destroy(owner);
    }

function getItemPossessorsInventory(InventoryItem item) returns (address a){
        return item.getOwningInventory();
    }

}

When I call the createWorld function from nethereum - I can see the transaction going in, I wait for the mining to complete, but my event is never fired?

Is what I am doing to complex for ethereum?
Note - the World contract then instantiates an Area contract, which then instantiates a Door object.

I am estimating the gas price by nethereums
var callResult = f.EstimateGasAsync(args).Result;

Where f is the function call.

My .Net code in nethereum looks like this:

public static string CreateWorld(string world)
        {
            var web3 = new Web3(Resources.Server);
            var result = web3.Personal.UnlockAccount.SendRequestAsync("0x54a222aE3d59EF92D715409f31C6eCAf331D0782", Resources.Password, 30).Result;
            if (result != true)
            {
                throw new Exception("Unable to unlock account...");
            }

            var d = Encoding.UTF8.GetBytes(world);

            string address = "0x30d578718e1da379f4B1B1ac5E9be9ba646E0bCF"; // Contract address
            var contract = web3.Eth.GetContract(Resources.ContractInterface2, address);

            var add = contract.GetFunction("createWorld");                         // Add method
            var worldCreatedEvent= contract.GetEvent("WorldCreated");
            var filterAll = worldCreatedEvent.CreateFilterAsync().Result;
            var totalGas = new HexBigInteger(GetGasPrice(add, d).Value*2);

            HexBigInteger gasPrice = new HexBigInteger(new BigInteger(0.144));

            var callResult = add.SendTransactionAsync("0x54a222aE3d59EF92D715409f31C6eCAf331D0782", totalGas,new HexBigInteger(0), d);
            var theResult = GetReceiptAsync(web3, callResult.Result);
            var log = worldCreatedEvent.GetAllChanges<dynamic>(filterAll).Result;

            return log[0].Event;
            return callResult.Result;
        }

No matter what, my log always ends up with 0 elements in it, and even using Ethereum Wallet - I don't see any contract events being raised.

Suggestions?


texts: Convert keccak256(abi.encodePacked(idToSeed[id])) in python

texts:
I am looking for python syntax to draw the autoglyphs using python.
Here is the few lines which I want to convert in python. I am new to it. Please help me out with this.
uint a = uint(uint160(keccak256(abi.encodePacked(idToSeed[id]))));
output[c] = prefix[c];
idToSymbolScheme[id] == 0
Here is the code in c++ which I trying to replicate  in python. https://www.larvalabs.com/autoglyphs


texts: Is it right to say: A contract account may contain more than one contract?

texts:
My question is related to my previous question:

Solidity: How can a contract B, burn from contract A, generate another contract?

As we can in the aforementioned post when we are deploying contract A, we're including all contracts A, B, and C in a transaction sent to the blockchain. So the contract account will contain all the contracts codes (even though contract B and C are not born yet).

Question:  Is it right to say a contract account may contain more than one contract?


texts: contractFactory always sending same address after deploying contract

texts:
i am developing a rental application using truffle with angular 5 for which i need to start a new contract everytime a new tenant rents a house from owner. For this purpose i have deployed a contractFactory using truffle. Following is my contractFactory

pragma solidity ^0.4.8;
import './RentalContract.sol';

contract contractFactory {
  address[] public contracts;

  function getContractCount() public constant returns(uint) {
    return contracts.length;
  }

  function newContract(uint _rent, uint _security_deposit, string _house, address _owner, address _tenant)
  public constant returns(address) {
    Rental c = new Rental(_rent, _security_deposit, _house, _owner, _tenant);
    contracts.push(c);
    return c;
  }
}

every time i need a new contract between owner and tenant i call newContract function of this contractFacotry, but the problem is that this contractFactory is always returning same address for every contract. Here is my angular service which makes use of web3 to call this contractFacotry function.

import { Injectable } from '@angular/core';
import * as Web3 from 'web3';
import {Observable} from 'rxjs/Observable';
import { fromPromise } from 'rxjs/observable/fromPromise';
import {observable} from "rxjs/symbol/observable";
import {reject} from "q";

const FactoryArtifacts = require('/home/work/angularplustruffle/angular4-truffle-starter-dapp/build/contracts/contractFactory.json');
const contract = require('truffle-contract');
const RentalArtifacts = require('/home/work/angularplustruffle/angular4-truffle-starter-dapp/build/contracts/Rental.json');

declare let require: any;
declare let window: any;

@Injectable()
export class ContractsService {
  ContractFactory = contract(FactoryArtifacts);
  Rental = contract(RentalArtifacts);
  private web3: any;
  public acc_no: any = 5;

  constructor() {
    if (typeof window.web3 !== 'undefined') {
      // Use Mist/MetaMask's provider
      this.web3 = new Web3(window.web3.currentProvider);
      this.ContractFactory.setProvider(window.web3.currentProvider);
      this.Rental.setProvider(window.web3.currentProvider);

      /* if (this.web3.version.network !== '4') {
        alert('Please connect to the Rinkeby network');
      } */
    } else {
      console.warn(
        'Please use a dapp browser like mist or MetaMask plugin for chrome'
      );
    }
  }
  public deployRentalContract(rent, security_deposit, house, owner, tenant): Observable<any> {
    let meta;
      return Observable.create( observer => {
        this.ContractFactory
          .deployed()
          .then( instance => {
              meta = instance;
              return meta.newContract(rent, security_deposit, house, owner, tenant);
          })
          .then(value => {
            console.log("value is");
            console.log(value);
            observer.next(value);
            observer.complete();
          })
          .catch(e => {
            console.log(e);
            observer.error(e);
          });
      });
  }
}

i have tried calling getContractCount() function from contract Factory but it is also returning zero all the time. any idea what is wrong here?