Example #1
0
export const publish = (publicKey, privateKey, payload, metadata) => {
    // Create a transation
    const tx = driver.Transaction.makeCreateTransaction(
        payload,
        metadata,
        [
            driver.Transaction.makeOutput(
                driver.Transaction.makeEd25519Condition(publicKey))
        ],
        publicKey
    )
    // sign/fulfill the transaction
    const txSigned = driver.Transaction.signTransaction(tx, privateKey)

    // send it off to BigchainDB
    return conn.postTransaction(txSigned)
        .then(() => conn.pollStatusAndFetchTransaction(txSigned.id))
        .then(() => txSigned)
}
Example #2
0
export const transfer = (tx, fromPublicKey, fromPrivateKey, toPublicKey, metadata) => {
    const txTransfer = driver.Transaction.makeTransferTransaction(
        tx,
        metadata,
        [
            driver.Transaction.makeOutput(
                driver.Transaction.makeEd25519Condition(toPublicKey)
            )
        ],
        0
    )

    const txTransferSigned = driver.Transaction.signTransaction(txTransfer, fromPrivateKey)
    // send it off to BigchainDB
    return conn.postTransaction(txTransferSigned)
        .then(() =>
            conn.pollStatusAndFetchTransaction(txTransferSigned.id))
        .then(() => txTransferSigned)
}