armutable
v0.0.4
Published
Mutability on Arweave
Downloads
3
Readme
armutable
Mutability on arweave
install
$ npm i armutable
usage
const armutable = require('armutable');
const fs = require('fs');
const arweave = require('arweave').init();
let jwk = JSON.parse(
fs.readFileSync('keyfile.json').toString()
);
// create a new "thread"
let myFile = fs.readFileSync('myfile.txt').toString();
armutable.newThread(arweave, myFile, jwk).then((result) => {
console.log(result);
// returns txID
});
// create a thread from a file already on arweave
let txid = "itloICInyOpUhUVMhgmWiHz7toruQ3xnlh14eC7bEOQ";
armutable.threadFromTX(arweave, txid, jwk).then((result) => {
console.log(result);
// new txID is the armutable thread
});
// update a thread
txid = "mvykkO-gle5AMLiGOcCi7i5BkbFWTs5XuM2gPh7BM4k";
let newfile = `function hello(){
console.log('this line has changed');
}`
armutable.updateThread(arweave, txid, newfile, jwk).then((result) => {
console.log(result);
});
// read a thread (using the `init` transaction ID)
armutable.readThread(arweave, txid).then((result) => {
console.log(result);
});
// allow another address to write changes
let address = "xEWtx87rhpoY-41RISu-i3GB7oNmsQWFQKUFNfl13bU";
armutable.authorizeAddress(arweave, txid, address, jwk).then((result) => {
// returns txid
console.log(result);
})