MutableDataInterface

MutableDataInterface

API to initialise new MutableData, Permissions, Entries, or EntryMutationTransaction instances.

Constructor

new MutableDataInterface(app)

Parameters:
Name Type Description
app SAFEApp

instance this is bound to

Source:

Methods

fromSerial() → {Promise.<MutableData>}

Create a new MutuableData object from serialised format

Source:
Example
// Assumes SAFEApp interface has been obtained
const asyncFn = async () => {
    try {
        let mData = await app.mutableData.newRandomPublic(15001);
        await mData.quickSetup({ });
        const serialisedMD = await mData.serialise();
        mData = await app.mutableData.fromSerial(serialisedMD);
    } catch (err) {
        throw err;
    }
};

newEntries() → {Promise.<Entries>}

Create a new Entries object.

Source:
Example
// Assumes SAFEApp interface has been obtained
const asyncFn = async () => {
    try {
        const mData = await app.mutableData.newRandomPublic(15001);
        const permissions = await app.mutableData.newEntries();
    } catch (err) {
        throw err;
    }
};

newMutation() → {Promise.<EntryMutationTransaction>}

Create a new EntryMutationTransaction object.

Source:
Example
// Assumes SAFEApp interface has been obtained
const asyncFn = async () => {
    try {
        const mData = await app.mutableData.newRandomPublic(15001);
        const permissions = await app.mutableData.newMutation();
    } catch (err) {
        throw err;
    }
};

newPermissions() → {Promise.<Permissions>}

Create a new Permissions object.

Source:
Example
// Assumes SAFEApp interface has been obtained
const asyncFn = async () => {
    try {
        const mData = await app.mutableData.newRandomPublic(15001);
        const permissions = await app.mutableData.newPermissions();
    } catch (err) {
        throw err;
    }
};

newPrivate(name, typeTag, secKey, nonce) → {Promise.<MutableData>}

Initiate a privateMutableData at the given address. Entries can be encrypted.

Parameters:
Name Type Description
name Buffer | String

32-byte name is the network address

typeTag Number
secKey Buffer | String
nonce Buffer | String
Source:
Example
// Assumes SAFEApp interface has been obtained
const asyncFn = async () => {
    try {
        const name = await app.crypto.sha3Hash('1010101010101');
        const encKeyPair = await app.crypto.generateEncKeyPair();
        const secKey = encKeyPair.secEncKey;
        const nonce = await app.crypto.generateNonce()
        const mData = await app.mutableData.newPrivate(name, 15002, secKey, nonce);
    } catch (err) {
        throw err;
    }
};

newPublic(32-byte, typeTag) → {Promise.<MutableData>}

Initiate a public MutableData at the given address

Parameters:
Name Type Description
32-byte Buffer | String

name is the network address

typeTag Number
Source:
Example
// Assumes SAFEApp interface has been obtained
const asyncFn = async () => {
    try {
        const name = await app.crypto.sha3Hash('1010101010101');
        const mData = await app.mutableData.newPublic(name, 15002);
    } catch (err) {
        throw err;
    }
};

newRandomPrivate(typeTag) → {Promise.<MutableData>}

Create a new private MutableData at a random address. Entrie can be encrypted.

Parameters:
Name Type Description
typeTag Number
Source:
Throws:
Example
// Assumes SAFEApp interface has been obtained
const asyncFn = async () => {
    try {
        const mData = await app.mutableData.newRandomPrivate(15001);
    } catch (err) {
        throw err;
    }
};

newRandomPublic(typeTag) → {Promise.<MutableData>}

Create a new public MutableData at a random address

Parameters:
Name Type Description
typeTag Number
Source:
Throws:
Example
// Assumes SAFEApp interface has been obtained
const asyncFn = async () => {
    try {
        const mData = await app.mutableData.newRandomPublic(15001);
    } catch (err) {
        throw err;
    }
};