Skip to content

Latest commit

 

History

History
24 lines (16 loc) · 765 Bytes

File metadata and controls

24 lines (16 loc) · 765 Bytes

Opacity Account Management

Example

import { createMnemonic, mnemonicToHandle } from "../ts-client-library/packages/util/src/mnemonic"
import { WebAccountMiddleware, WebNetworkMiddleware } from "../ts-client-library/packages/middleware-web"

const storageNode = "http://broker-1.opacitynodes.com:3000"

const mnemonic = await createMnemonic()
const handle = await mnemonicToHandle(mnemonic)

const cryptoMiddleware = new WebAccountMiddleware({ asymmetricKey: handle })
const netMiddleware = new WebNetworkMiddleware()

const account = new Account({ crypto: cryptoMiddleware, net: netMiddleware, storageNode })

const invoice = await account.signUp({ size: 10 })
console.log(invoice)
await account.waitForPayment()

console.log(await account.info())