Uport for Developers

Learn the best way to bring users to your apps


Sign up for our Developer Alpha

Get Started

The interactive tutorials on this site require the use of the uPort mobile app. If you don’t have the mobile app installed, sign up for our alpha

Connect with uPort

One of the most basic things you should do is allow your user to connect their uPort to your app.

1
2
3
4
5
6
7
import { Connect } from 'uport-connect'

let uport = new Connect('MyDApp')

uport.requestCredentials().then((credentials) => {
  console.log(credentials)
})

Write user friendly Ethereum dApps

If you’re writing dApps for Ethereum, you are probably using web3. Uport allows you write your Ethereum apps like normal yet allow your users to not worry about getting Ethereum setup on their computer. The uPort app manages that for you.

In the following example the Status smart contract is called setting your status:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
import { Connect } from 'uport-connect'

let uport = new Connect('MyDApp')

let web3 = uport.getWeb3()

let statusAbi = [{'constant': false, 'inputs': [{'name': 'status', 'type': 'string'}], 'name': 'updateStatus', 'outputs': [], 'type': 'function'}, {'constant': false, 'inputs': [{'name': 'addr', 'type': 'address'}], 'name': 'getStatus', 'outputs': [{'name': '', 'type': 'string'}], 'type': 'function'}]

let statusContract = web3.eth.contract(statusAbi)
let statusFunction = statusContract.at('0xB42E70a3c6dd57003f4bFe7B06E370d21CDA8087')

statusFunction.updateStatus(text, function(error, txhash) {
  console.log(txhash)
})

Try it yourself:

Call updateStatus()

In most cases the web3 object acts like you would expect, but if you need your users address for example you can just call web3.eth.getAccounts() and we ask the app.

1
2
3
4
5
6
7
8
9
import { Connect } from 'uport-connect'

let uport = new Connect('MyDApp')

let web3 = uport.getWeb3()

web3.eth.getAccounts(function(error, accounts) {
  console.log(accounts)
})

Try it yourself:

Call getAccounts()

Learn more

To go into more details of how uport lib works try our tutoral showing you how to create a simple wallet using uPort.