Created
November 6, 2019 20:29
-
-
Save iamonuwa/483c097b50f6e1f2b677a9111b49c40b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const tx = await arweave.createTransaction( | |
{ data: JSON.stringify(data) }, | |
key | |
); | |
console.log(tx); | |
tx.addTag("App-Name", "demo"); | |
tx.addTag("App-Version", "0.0.1"); | |
tx.addTag("Unix-Time", Math.round(new Date().getTime() / 1000)); | |
tx.addTag("Type", "publish"); | |
console.log(tx); | |
await arweave.transactions.sign(tx, key); | |
console.log(tx.id); | |
let { status } = await arweave.transactions.post(tx); | |
let payload = {};
const tx = await arweave.createTransaction(
{
data: payload
},
key
);
const { data } = await arweave.api.get("/tx_anchor");
tx.last_tx = data;
console.log(tx);
tx.addTag("App-Version", "0.0.1");
tx.addTag("title", "Demo");
tx.addTag("author", address);
tx.addTag("data", state.file);
tx.addTag("createdAt", Math.round(new Date().getTime() / 1000));
tx.addTag("Type", "publish");
await arweave.transactions.sign(tx, key);
let { status } = await arweave.transactions.post(tx);
if (status === 200) {
// trigger success alert
console.log("Saved successfully");
} else if (status === 400) {
// trigger failed to save document
console.log("Failed to save document");
} else {
// trigger internal server error
console.log("Internal server error.");
}```
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The error is on L17