0

Is it possible to speak with a Dapp (or with a smart contract) stored on my private network from mobile?

1

Read data

If you want to read data (call a constant method to read a state), you can do it from any mobile browser (like Chrome).

You first need to connect to a node

var web3 = new Web3(new Web3.providers.HttpProvider(PRIVATE_NODE_RPC_ENDPOINT));

and then make a smart contract as explained here

// contract abi
var abi = [{
     name: 'myConstantMethod',
     type: 'function',
     constant: true,
     inputs: [{ name: 'a', type: 'string' }],
     outputs: [{name: 'd', type: 'string' }]
}, {
     name: 'myStateChangingMethod',
     type: 'function',
     constant: false,
     inputs: [{ name: 'a', type: 'string' }, { name: 'b', type: 'int' }],
     outputs: []
}, {
     name: 'myEvent',
     type: 'event',
     inputs: [{name: 'a', type: 'int', indexed: true},{name: 'b', type: 'bool', indexed: false}]
}];

// creation of contract object
var MyContract = web3.eth.contract(abi);

// initiate contract for an address
var myContractInstance = MyContract.at('0xc4abd0339eb8d57087278718986382264244252f');

// call constant function
var result = myContractInstance.myConstantMethod('myParam');
console.log(result) // '0x25434534534'

Write data

However, if you want to write data, you need to send a transaction which means you need a private key (basically a wallet).

There are a few Ethereum Mobile browsers on the market like Status, Toshi or Cipher. I just checked and no one accepts yet to connect to a private node via RPC (only public networks like mainet, ropsten, rinkeby). You will need to wait the feature to be implemented on one of those or a new Ethereum mobile wallet with this feature.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.