Minka Ledger Docs
How To Guides

How to set up access rules based on policies

DateResponsibleChanges
June 14, 2023@Luis FidelisInitial version

Each access rule supports attaching policies through the policy property. This property holds the handle of policy that is being reused by the record.

Follow an example of a wallet that attaches two policies to its list of access rules by Ledger SDK.

import { LedgerSdk } from '@minka/ledger-sdk'
 
const sdk = new LedgerSdk({
    server: '<your ledger URL>',
    signer: {
        format: 'ed25519-raw',
        public: '<your ledger public key>'
    }
})
 
await sdk.policy.init()
    .data({
        handle: 'wallet-reader',
        record: 'wallet',
        values: [{
            action: 'read',
            bearer: {
                $signer: {
                    $circle: 'bank'
                }
            }
        }]
    })
    .hash()
    .sign([{ keyPair: yourKeyPair }])
    .send()
 
await sdk.policy.init()
    .data({
        handle: 'wallet-updater',
        record: 'wallet',
        values: [{
            action: 'update',
            signer: {
                $circle: 'bank'
            }
        }]
    })
    .hash()
    .sign([{ keyPair: yourKeyPair }])
    .send()
import { LedgerSdk } from '@minka/ledger-sdk'
 
const sdk = new LedgerSdk({
    server: '<your ledger URL>',
    signer: {
        format: 'ed25519-raw',
        public: '<your ledger public key>'
    }
})
 
const { wallet } = await sdk.wallet.init()
    .data({
        handle: 'test-wallet',
        access: [{
            policy: 'wallet-reader'
        }, {
            policy: 'wallet-updater' 
        }]
    })
    .hash()
    .sign([{ keyPair: yourKeyPair }])
    .send()

On this page