title | index | category | type |
---|---|---|---|
uPort Identity Contracts |
7 |
reference |
content |
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.
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.
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.
The most important interactions with the contracts are creation of identities and sending transactions. Here are visual representations of this being executed.
Add a new entry in ./truffle.js
like so:
yourNetwork: {
get provider() {
return getProvider("http://my-private.network/")
},
network_id: "*"
},
If the gas price on the network is very high you might need to add the gasPrice
parameter.
Create a file called ./seed
. This file should contain a mnemonic seed phrase. Make sure that the first address of this seed has ether on your private network. Then run:
$ yarn _deploy yourNetwork
The addresses of the deployed contracts should then be located in ./build/contracts/{ContractName}.json
.