@ocap/statedb-dolt

1.20.14 • Public • Published

styled with prettier

Install

npm install @ocap/statedb-dolt
// or
pnpm install @ocap/statedb-dolt

Usage

const DOLTStateDB = require('@ocap/statedb-dolt');

const db = new DOLTStateDB({
  connection: 'mysql://root:@127.0.0.1:3306',
});

db.onReady(async () => {
  const account = {
    address: 'z1VUFgtw9JSENAswYm5vqdpg461oi6JPEdP',
    balance: '100000000000000000000000000',
    gasBalance: '0',
    nonce: 2,
    numTxs: 1,
    numAssets: 0,
    migratedTo: [],
    migratedFrom: [],
    stake: null,
    context: {
      genesisTime: '2021-02-02T02:17:48.141Z',
      genesisTx: '',
      renaissanceTime: '2021-02-02T02:17:48.141Z',
      renaissanceTx: '',
    },
    moniker: 'system',
  };

  await db.runAsLambda(async (txn) => {
    const exist = await db.account.get(account.address, { txn });
    console.log('account', { exist });

    if (!exist) {
      const created = await db.account.create(account.address, account, { txn });
      console.log('account', { created });
    }
  });
});

Package Sidebar

Install

npm i @ocap/statedb-dolt

Weekly Downloads

52

Version

1.20.14

License

Apache-2.0

Unpacked Size

37.3 kB

Total Files

20

Last publish

Collaborators

  • wangshijun
  • polunzh
  • mave99a