For a final year computer science project I'm building (or attempting to build) a mobile frontend for my dapp.

The client will use the wallet offered by web3.eth.accounts to sign transactions locally (the Keystore file is stored locally, also, and never leaves the client - encrypted or otherwise).

I'm also utilising truffle to make Smart Contract development easier.

Now: taking into account that transactions are signed locally without the help of Metamask etc. - for the truffle abstractions, namely its abstraction of the ABI, should I serve these from a node.js backend? I'm struggling conceptually with the potential flow.


Excuse me if I am oversimplifying or misunderstanding your question. It sounds like you are just looking for a way to use web3 on mobile without metamask. I will begin by referring you to this question about how dapps can work on mobile, although it is somewhat outdated it can give you some context.

This question shows a list of web3-js enabled mobile browsers.

In doing some research I stumbled across this helpful [Coinbase Wallet developer doc] which shows how to both check for mobile and web3 enabled browsers using javascript I will paste the code below for convenience.

// Check for mobile
const { userAgent: ua } = navigator
const isIOS = ua.includes('iPhone') // “iPhone OS”
const isAndroid = ua.includes('Android')

// Check for web3 enabled browsers
const { currentProvider: cp } = window.web3
const isToshi = !!cp.isToshi
const isCipher = !!cp.isCipher
const isStatus = !!cp.isStatus
const isTrust = !! cp.isTrust
const isMetaMask = !!cp.isMetaMask

Okay now we know whether we are mobile or desktop and if we have a web3 enabled browser. Next we want to start calling contract methods. This question shows us how to call contract methods with web3. Again I will paste a generalized version here for convenience and clarity.

/* First get the contract instance from the abi,
   which should be stored locally in your dApp.
const contract = web3.eth.contract(contractAbi)
const contractInstance = contract.at(contractAddress)

contractInstance.myMethod.(param1 [, param2, ...] 
                           [, transactionObject]
                           [, defaultBlock]
                           [, callback]);

Finally, you specifically asked about signing transactions. The Coinbase doc that I liked above has a section about that:

  jsonrpc: '2.0',
  id: 1,
  method: 'personal_sign',
  params: [
    '0x48656c6c6f20576f726c6421', // message
    '0x4c37E2533D4B1c9aAA5d1bc31dd7259A0852F0E4' // address
}, (err, res) => {
  console.log(err, res)

This is taken from page 26. It also explains the use of personal_sign over the other signing methods.

Note: If this answer is what you are looking for, it may be useful to reformulate the header of this question to more accurately reflect what was being asked and what was answered.

Let me know if this helps at all! 🙂


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.