Skip to content

Latest commit

 

History

History
76 lines (58 loc) · 3.47 KB

readme-template.md

File metadata and controls

76 lines (58 loc) · 3.47 KB

uPort Identity Contracts

npm CircleCI Join the chat at

Please read our Whitepaper for information on what uPort is, and what is currently possible as far as integration.

Using the contracts

To use the contract we provide truffle artifacts. Once you require the uport-identity module you will get an object containing a versioned index of the uport contracts. You can specify which version you want to user, or just use the latest one. Keep in mind that different versions will be deployed to different addresses.

const uportIdentity = require('uport-identity')
const Contract = require('truffle-contract')

// use specific version
const IdentityManagerArtifact = uportIdentity.IdentityManager.v1

// or use latest version
const version = uportIdentity.IdentityManager.latestVersion
const IdentityManagerArtifact = uportIdentity.IdentityManager[version]

You can use truffle-contract to utilize these artifacts.

let IdentityManager = Contract(IdentityManagerArtifact)
IdentityManager.setProvider(web3.currentProvider)
let identityManager = IdentityManager.deployed()

You can also use web3.

let networkId = 1 // Mainnet
let IdentityManager = web3.eth.contract(IdentityManagerArtifact)
let identityManager = IdentityManager.at(IdentityManagerArtifact.networks[networkId].address)

If you want to learn more about this structure, checkout the document about the artifact index.

Testing the contracts

All aspects of the contracts need to be tested. To do this we use truffle and testrpc behind the scenes. Right now we only have tests written in javascript, but in the future we plan on adding tests written in solidity as well.

To execute the tests you simply run:

$ yarn test

If you want to run run a specific test you can just add the filename:

$ yarn test test/testName.js

You can also run the tests on a geth node.

Contract documentation

This repository contains the contracts currently in use by uPort. This is also where you find the addresses of these contracts currently deployed on Mainnet and relevant test networks. Below you can find descriptions of each of the contracts and the rationale behind the design decisions.

Main contract interactions

The most important interactions with the contracts are creation of identities and sending transactions. Here are visual representations of this being executed.

Creating an identity with the IdentityManager

identity creation

Transfer an identity to IdentityManager

register identity

Send a meta-tx

meta-tx

Contributing

Want to contribute to uport-contracts? Cool, please read our contribution guidelines to get an understanding of the process we use for making changes to this repo.