How to sign documents

Universal Wallet uses 3ID Protocol and IPLD to manage decentralized content and uses DID to sign content

Example

// get existing account
let acct = await wallet.getAccount()

// add wallet with auto generated mnemonic
const walletId = await wallet.addWallet()

// get keypair
const result = await wallet.createEd25519({
  rpcUrl: url,
  walletId,
  registry: '',
})

// init IPLD manager
const ipfsManager = new IPLDManager(result.did)
await ipfsManager.start()

// create document
const fil = Buffer.from('fffffffffffffffffffffff')

// authentication
await result.did.authenticate()

// addSignedObject add a Buffer with props using a File-like interface
const cid = await ipfsManager.addSignedObject(fil, {
  name: 'UnitTest.txt',
  contentType: 'text/text',
  lastModified: new Date(),
})
expect(cid.length).toBeGreaterThan(0)

// Get recent object
const res = await ipfsManager.getObject(cid)
expect(res.value.name).toEqual('UnitTest.txt')

Last updated