{"_id":"@arconnect/arweave","_rev":"2-2a514aed4ce3ae81eea71312a350e61f","name":"@arconnect/arweave","dist-tags":{"latest":"1.11.6"},"versions":{"1.11.6":{"name":"@arconnect/arweave","version":"1.11.6","keywords":["arweave","js","blockchain","crypto","data","permanence","http"],"author":{"name":"Arweave Team","email":"team@arweave.org"},"license":"MIT","_id":"@arconnect/arweave@1.11.6","maintainers":[{"name":"martondev","email":"martondeveloper@gmail.com"}],"contributors":[{"name":"Kyle Beckles","email":"kyle@arweave.org"},{"name":"Aidan O'Kelly","email":"aidan@arweave.org"},{"name":"Ros McMahon","email":"ros@arweave.org"},{"name":"Cedrik Boudreau","email":"cedrik@arweave.org"}],"homepage":"https://github.com/ArweaveTeam/arweave-js#readme","bugs":{"url":"https://github.com/ArweaveTeam/arweave-js/issues"},"dist":{"shasum":"c9f290f7a371fb57d23ce452ca352acefe03d484","tarball":"https://registry.npmjs.org/@arconnect/arweave/-/arweave-1.11.6.tgz","fileCount":131,"integrity":"sha512-usWP3hGhoUD5ljDjpRAa2QpvixbAsiWE7HSTsKShtX7Zh925pCn6gASTN22JM26c/W+2NMS1Q/Fcn7SNoM4xIw==","signatures":[{"sig":"MEYCIQCkpzQcLBBWsGNMuBonXTQZeKPpG67ST4i5GJ6CkT6mpQIhAMuewvDNuwc0P4HjMhlBhnbsSp6UO/7RzGwDnp7I9ZY4","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":1299351,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjeVHeACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmorExAAnuXZTzBR0hE+N6hbaMcHEbl7DTF6+lw9JcOTOpgVAprss+MC\r\nCyc3SV1VS5M8WKT4V6n7fJZe1tAUw1LoNuEXsPsVFshApu8lWPiCWntRet6f\r\n8jOueS01TD1OA6HErwDtUVeP/pJWez2fGHn575Q2IPrSe1gUHSb3Fme9C6of\r\neXa82dwIqLYlZjl91PUFHJvG0zhF1bhKTKtC5CPmLrS1RvYosSg7DzRDcX4C\r\nmjnqCfkSVXLBF8GNS1qpikWrSB2xzO7y3EvJniFVZdmArJK1vxGgAhmGU4up\r\n9Na7z8PjiEKTl3Us+4lcMDh0ZBf4jD6KdiyNfPvTTK9bpZJCfpiBIfU08ls5\r\ndm8dnBsEjaopGxnw65B8sZQfxh+4DxYZZIKbH+XG57IsnWboHxsXJ4y2WMdh\r\n3wQtKc7CAMieEMSwR6uPYDr6W4AcfKw1C137edU8eF3xSgpeGWvKwe2y9OVV\r\nCWu4LDU6fAdmpEdtkm1nazCSPCHc2FXdc4Njuxcpi4QXUjXJRHkDgmtz6U/A\r\nRsg5zu5RO64A9Ei2K37eD1kcprCQaWTWTREUDdCaLGyaxczcWCizUJzsaVPT\r\nO98VrnbYiaxcdYx+Qed+1rDvgFUvittMMy2WIpD/C3PrFPxWZUIMkxIpLMID\r\nzpS38+rdYcCbnFNWboPMANAWzXonr2E8dpE=\r\n=kslR\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./node/index.js","types":"./node/index.d.ts","browser":"./web/index.js","engines":{"node":">=12"},"gitHead":"f401d9f3d1a487327da510c8853599777dfb6897","private":false,"scripts":{"test":"mocha -r ts-node/register -r tsconfig-paths/register test/*.ts && echo \"NOW RUN => 'npm run test:web' <= \" ","build":"npm run clean && npm run compile:node && npm run compile:web && npm run package && npm run bundle:web && npm run bundle:web-prod","clean":"npm run clean:dist && npm run clean:package && npm  run clean:bundle","package":"mkdirp node web && ncp dist/node/common/ dist/node/node/ && ncp dist/node/node/ node && ncp dist/web/common/ dist/web/web/ && ncp dist/web/web/ web && npm run clean:dist","version":"npm run prettier:write && git add -A src && git add -A test","test:web":"npm run bundle:web && npx webpack --config-name web-tests && opener test/web/web.html","bundle:web":"npx webpack --config-name web","clean:dist":"rimraf dist","preversion":"npm run test","compile:web":"tsc --declaration -project tsconfig.web.json && resolve-tspaths -p tsconfig.web.json","postversion":"git push && git push --tags","profile:web":"npx webpack --config-name web --json > ./web.profile.json && npx webpack-bundle-analyzer ./web.profile.json","clean:bundle":"rimraf bundles","compile:node":"tsc --declaration -project tsconfig.node.json && resolve-tspaths -p tsconfig.node.json","clean:package":"rimraf node web","prepublishOnly":"npm run clean && npm run build","prettier:check":"prettier --check \"src/**/*.ts\" \"test/**/*.ts\"","prettier:write":"prettier --write \"src/**/*.ts\" \"test/**/*.ts\"","bundle:web-prod":"npx webpack --config-name web-prod"},"targets":{"node":"12","chrome":"70"},"_npmUser":{"name":"martondev","email":"martondeveloper@gmail.com"},"repository":{"url":"git+https://github.com/ArweaveTeam/arweave-js.git","type":"git"},"_npmVersion":"8.1.0","description":"Arweave JS client library","directories":{},"_nodeVersion":"16.13.0","dependencies":{"util":"^0.12.4","axios":"^0.27.2","asn1.js":"^5.4.1","arconnect":"^0.4.2","base64-js":"^1.5.1","bignumber.js":"^9.0.2","@vespaiach/axios-fetch-adapter":"^0.3.1"},"react-native":"./node/index.js","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"ncp":"^2.0.0","chai":"^4.3.6","mocha":"^10.0.0","buffer":"^6.0.3","mkdirp":"^1.0.4","opener":"^1.5.2","rimraf":"^3.0.2","process":"^0.11.10","ts-node":"^10.8.0","webpack":"^5.72.1","prettier":"2.6.2","ts-loader":"^9.3.0","typescript":"^4.7.2","@types/chai":"^4.3.1","@types/node":"^17.0.38","webpack-cli":"^4.9.2","@types/mocha":"^9.1.1","tsconfig-paths":"^4.0.0","resolve-tspaths":"^0.6.0","@types/base64-js":"^1.3.0","crypto-browserify":"^3.12.0","stream-browserify":"^3.0.0","terser-webpack-plugin":"^5.3.3","webpack-bundle-analyzer":"^4.5.0"},"_npmOperationalInternal":{"tmp":"tmp/arweave_1.11.6_1668895197818_0.8643205832494438","host":"s3://npm-registry-packages"}}},"time":{"created":"2022-11-19T21:59:57.745Z","modified":"2024-11-23T22:38:35.721Z","1.11.6":"2022-11-19T21:59:58.063Z"},"bugs":{"url":"https://github.com/ArweaveTeam/arweave-js/issues"},"author":{"name":"Arweave Team","email":"team@arweave.org"},"license":"MIT","homepage":"https://github.com/ArweaveTeam/arweave-js#readme","keywords":["arweave","js","blockchain","crypto","data","permanence","http"],"repository":{"url":"git+https://github.com/ArweaveTeam/arweave-js.git","type":"git"},"description":"Arweave JS client library","contributors":[{"name":"Kyle Beckles","email":"kyle@arweave.org"},{"name":"Aidan O'Kelly","email":"aidan@arweave.org"},{"name":"Ros McMahon","email":"ros@arweave.org"},{"name":"Cedrik Boudreau","email":"cedrik@arweave.org"}],"maintainers":[{"email":"martondeveloper@gmail.com","name":"martondev"},{"email":"nma@communitylabs.com","name":"nickeeeeyyyy"},{"email":"mparij@gmail.com","name":"7i7o"}],"readme":"# Arweave JS \n\nArweave JS is the JavaScript/TypeScript SDK for interacting with the Arweave network and uploading data to the permaweb. It works in latest browsers and Node JS.\n\n**Note:** If you are planning to upload large batches of data transactions to the Arweave network, it is strongly advised that you use [ArBundles](https://github.com/Bundler-Network/arbundles) instead of transactions with Arweave.js. You can read about bundles and their advantages on the [Arwiki](https://arwiki.wiki/#/en/bundles).\n\n- [Arweave JS](#arweave-js)\n  - [Installation](#installation)\n    - [NPM](#npm)\n    - [Bundles](#bundles)\n  - [Initialisation](#initialisation)\n    - [NPM Node](#npm-node)\n    - [NPM Web](#npm-web)\n    - [Web Bundles](#web-bundles)\n    - [Initialisation options](#initialisation-options)\n  - [Usage](#usage)\n    - [Wallets and Keys](#wallets-and-keys)\n      - [Create a new wallet and private key](#create-a-new-wallet-and-private-key)\n      - [Get the wallet address for a private key](#get-the-wallet-address-for-a-private-key)\n      - [Get an address balance](#get-an-address-balance)\n      - [Get the last transaction ID from a wallet](#get-the-last-transaction-id-from-a-wallet)\n    - [Transactions](#transactions)\n      - [Create a data transaction](#create-a-data-transaction)\n      - [Create a wallet to wallet transaction](#create-a-wallet-to-wallet-transaction)\n      - [Add tags to a transaction](#add-tags-to-a-transaction)\n      - [Sign a transaction](#sign-a-transaction)\n      - [Submit a transaction](#submit-a-transaction)\n        - [Chunked uploading advanced options](#chunked-uploading-advanced-options)\n      - [Get a transaction status](#get-a-transaction-status)\n      - [Get a transaction](#get-a-transaction)\n      - [Get transaction data](#get-transaction-data)\n      - [Decode tags from transactions](#decode-tags-from-transactions)\n    - [Blocks](#blocks)  \n      - [Get a block by indep_hash](#get-a-block-by-indep_hash)\n      - [Get current block](#get-current-block)\n    - [GraphQL](#graphql)\n    - [License](#license)\n\n## Installation\n### NPM\n```bash\nnpm install --save arweave\n```\n\n### Bundles\nSingle bundle file (web only - use the NPM method if using Node).\n\n```html\n<!-- Latest -->\n<script src=\"https://unpkg.com/arweave/bundles/web.bundle.js\"></script>\n\n<!-- Latest, minified-->\n<script src=\"https://unpkg.com/arweave/bundles/web.bundle.min.js\"></script>\n\n<!-- Specific version -->\n<script src=\"https://unpkg.com/arweave@1.2.0/bundles/web.bundle.js\"></script>\n\n<!-- Specific version, minified -->\n<script src=\"https://unpkg.com/arweave@1.2.0/bundles/web.bundle.min.js\"></script>\n```\n\n\n## Initialisation\n\n### NPM Node\n```js\nconst Arweave = require('arweave');\n\n// If you want to connect directly to a node\nconst arweave = Arweave.init({\n    host: '127.0.0.1',\n    port: 1984,\n    protocol: 'http'\n});\n\n// Or to specify a gateway when running from NodeJS you might use\nconst arweave = Arweave.init({\n  host: 'arweave.net',\n  port: 443,\n  protocol: 'https'\n});\n```\n\n### NPM Web\n```js\nimport Arweave from 'arweave';\n\n// Since v1.5.1 you're now able to call the init function for the web version without options. The current URL path will be used by default. This is recommended when running from a gateway.\nconst arweave = Arweave.init({});\n\n// Or manually specify a host\nconst arweave = Arweave.init({\n    host: '127.0.0.1',\n    port: 1984,\n    protocol: 'http'\n});\n```\n\n### Web Bundles\n```js\n<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta charset=\"UTF-8\">\n    <title>Hello world</title>\n    <script src=\"https://unpkg.com/arweave/bundles/web.bundle.js\"></script>\n    <script>\n    const arweave = Arweave.init({});\n    arweave.network.getInfo().then(console.log);\n    </script>\n</head>\n<body>\n\n</body>\n</html>\n```\n\n### Initialisation options\n```js\n{\n    host: 'arweave.net',// Hostname or IP address for a Arweave host\n    port: 443,          // Port\n    protocol: 'https',  // Network protocol http or https\n    timeout: 20000,     // Network request timeouts in milliseconds\n    logging: false,     // Enable network request logging\n}\n```\n\n## Usage\n\n### Wallets and Keys\n\n#### Create a new wallet and private key\n\nHere you can generate a new wallet address and private key ([JWK](https://docs.arweave.org/developers/server/http-api#key-format)), don't expose private keys or make them public as anyone with the key can use the corresponding wallet.\n\nMake sure they're stored securely as they can never be recovered if lost.\n\nOnce AR has been sent to the address for a new wallet, the key can then be used to sign outgoing transactions.\n```js\narweave.wallets.generate().then((key) => {\n    console.log(key);\n    // {\n    //     \"kty\": \"RSA\",\n    //     \"n\": \"3WquzP5IVTIsv3XYJjfw5L-t4X34WoWHwOuxb9V8w...\",\n    //     \"e\": ...\n});\n```\n\n#### Get the wallet address for a private key\n\n```js\narweave.wallets.jwkToAddress(key).then((address) => {\n    console.log(address);\n    //1seRanklLU_1VTGkEk7P0xAwMJfA7owA1JHW5KyZKlY\n});\n```\n\n#### Get an address balance\nGet the balance of a wallet address, all amounts by default are returned in [winston](https://docs.arweave.org/developers/server/http-api#ar-and-winston).\n```js\narweave.wallets.getBalance('1seRanklLU_1VTGkEk7P0xAwMJfA7owA1JHW5KyZKlY').then((balance) => {\n    let winston = balance;\n    let ar = arweave.ar.winstonToAr(balance);\n\n    console.log(winston);\n    //125213858712\n\n    console.log(ar);\n    //0.125213858712\n});\n```\n\n#### Get the last transaction ID from a wallet\n\n```js\narweave.wallets.getLastTransactionID('1seRanklLU_1VTGkEk7P0xAwMJfA7owA1JHW5KyZKlY').then((transactionId) => {\n    console.log(transactionId);\n    //3pXpj43Tk8QzDAoERjHE3ED7oEKLKephjnVakvkiHF8\n});\n```\n\n### Transactions\n\nTransactions are the building blocks of the Arweave permaweb. They can send [AR](https://docs.arweave.org/developers/server/http-api#ar-and-winston) between wallet addresses or store data on the Arweave network.\n\nThe create transaction methods create and return an unsigned transaction object. You must sign the transaction and submit it separately using the `transactions.sign` and `transactions.submit` methods.\n\nIf you don't pass in a `key` argument when creating a transaction, Arweave.js will attempt to use a browser-based wallet extension, such as [ArConnect](https://arconnect.io) or [Finnie](https://koii.network/getFinnie), to sign the transaction.\n\n**Modifying a transaction object after signing it will invalidate the signature,** causing it to be rejected by the network if submitted in that state. Transaction prices are based on the size of the data field, so modifying the data field after a transaction has been created isn't recommended as you'll need to manually update the price.\n\nThe transaction ID is a hash of the transaction signature, so a transaction ID can't be known until its contents are finalised and it has been signed.\n\n#### Create a data transaction\n\n**Note:** If you are planning to upload large batches of data transactions to the Arweave network, it is strongly advised that you use [ArBundles](https://github.com/Bundler-Network/arbundles) instead of transactions with Arweave.js. You can read about bundles and their advantages on the [Arwiki](https://arwiki.wiki/#/en/preview/WUAtjfiDQEIqhsUcHXIFTn5ZmeDIE7If9hJREBLRgak).\n\nData transactions are used to store data on the Arweave permaweb. They can contain HTML or any arbitrary data and are served like webpages.\n\n```js\nlet key = await arweave.wallets.generate();\n\n// Plain text\nlet transactionA = await arweave.createTransaction({\n    data: '<html><head><meta charset=\"UTF-8\"><title>Hello world!</title></head><body></body></html>'\n}, key);\n\n// Buffer\nlet transactionB = await arweave.createTransaction({\n    data: Buffer.from('Some data', 'utf8')\n}, key);\n\n\nconsole.log(transactionA);\n// Transaction {\n//   format: 2,\n//   id: 'ReUohI9tEmXQ6EN9H9IkRjY9bSdgql_OdLUCOeMEte0',\n//   last_tx: 'Tk-0c7260Ya5zjfjzl4f6-W-vRO94qiqZMAScKBcYXc68v1Pd8bYfTbKWi7pepUF',\n//   owner: 'kmM4O08BJB85RbxfQ2nkka9VNO6Czm2Tc_IGQNYCTSXRzO...',\n//   tags: [],\n//   target: '',\n//   quantity: '0',\n//   data: 'c29tZSBkYXRh',\n//   data_size: '9',\n//   data_root: 'qwKZUl7qWpCEmB3cpONKTYOcSmnmhb-_s8ggMTZwCU4',\n//   data_tree: [],\n//   reward: '7489274',\n//   signature: 'JYdFPblDuT95ky7_wVss3Ax9e4Qygcd_lEcB07sDPUD_wNslOk...'\n// }\n```\n\n#### Create a wallet to wallet transaction\n\nWallet to wallet transactions can facilitate payments from one wallet to another, given a target wallet and AR token quantity in Winston.\n\n```js\nlet key = await arweave.wallets.generate();\n\n// Send 10.5 AR to 1seRanklLU_1VTGkEk7P0xAwMJfA7owA1JHW5KyZKlY\nlet transaction = await arweave.createTransaction({\n    target: '1seRanklLU_1VTGkEk7P0xAwMJfA7owA1JHW5KyZKlY',\n    quantity: arweave.ar.arToWinston('10.5')\n}, key);\n\nconsole.log(transaction);\n// Transaction {\n//   format: 2,\n//   id: 'v-n7hAc7cubeXSClh0beaOs1RjYFagyvpl2TkUOfbRg',\n//   last_tx: 'Tk-0c7260Ya5zjfjzl4f6-W-vRO94qiqZMAScKBcYXc68v1Pd8bYfTbKWi7pepUF',\n//   owner: 'kmM4O08BJB85RbxfQ2nkka9VNO6Czm2Tc_IGQNYCTSXRzOc6W9b...',\n//   tags: [],\n//   target: '1seRanklLU_1VTGkEk7P0xAwMJfA7owA1JHW5KyZKlY',\n//   quantity: '10500000000000',\n//   data: '',\n//   data_size: '0',\n//   data_root: '',\n//   data_tree: [],\n//   reward: '7468335',\n//   signature: 'DnUOYbRSkhI4ZXg5fpYDCwPv8yvM5toAneSx4Jlg0zjIocqPs8giPP...'\n// }\n```\n\n#### Add tags to a transaction\n\nMetadata can be added to transactions through tags, these are simple key/value attributes that can be used to document the contents of a transaction or provide related data.\n\n[GraphQL](#graphql) uses tags when searching for transactions.\n\nThe `Content-Type` is a reserved tag and is used to set the data content type. For example, a transaction with HTML data and a content type tag of `text/html` will be served as a HTML page and render correctly in browsers,\nif the content type is set to `text/plain` then it will be served as a plain text document and not render in browsers.\n\n```js\nlet key = await arweave.wallets.generate();\n\nlet transaction = await arweave.createTransaction({\n    data: '<html><head><meta charset=\"UTF-8\"><title>Hello world!</title></head><body></body></html>',\n}, key);\n\ntransaction.addTag('Content-Type', 'text/html');\ntransaction.addTag('key2', 'value2');\n\nconsole.log(transaction);\n// Transaction {\n//   format: 2,\n//   id: '',\n//   last_tx: 'Tk-0c7260Ya5zjfjzl4f6-W-vRO94qiqZMAScKBcYXc68v1Pd8bYfTbKWi7pepUF',\n//   owner: 'kmM4O08BJB85RbxfQ2nkka9VNO6Czm2Tc_IGQNYC...',\n//   tags: [\n//     Tag { name: 'Q29udGVudC1UeXBl', value: 'dGV4dC9odG1s' },\n//     Tag { name: 'a2V5Mg', value: 'dmFsdWUy' }\n//   ],\n//   target: '',\n//   quantity: '0',\n//   data: 'PGh0bWw-PGhlYWQ-PG1ldGEgY2hhcnNldD0iVVRGLTgiPjx0aXRsZT5IZWxsbyB3b3JsZCE8L3RpdGxlPjwvaGVhZD48Ym9keT48L2JvZHk-PC9odG1sPg',\n//   data_size: '88',\n//   data_root: 'GQunzmbwk2_JPU7oJOmLrTMvj8v_7BJaF0weyjVn5Nc',\n//   data_tree: [],\n//   reward: '7673074',\n//   signature: ''\n// }\n```\n\n#### Sign a transaction\n\n```js\nlet key = await arweave.wallets.generate();\n\nlet transaction = await arweave.createTransaction({\n    target: '1seRanklLU_1VTGkEk7P0xAwMJfA7owA1JHW5KyZKlY',\n    quantity: arweave.ar.arToWinston('10.5')\n}, key);\n\nawait arweave.transactions.sign(transaction, key);\n\nconsole.log(transaction);\n// Transaction {\n//   format: 2,\n//   id: 'v-n7hAc7cubeXSClh0beaOs1RjYFagyvpl2TkUOfbRg',\n//   last_tx: 'Tk-0c7260Ya5zjfjzl4f6-W-vRO94qiqZMAScKBcYXc68v1Pd8bYfTbKWi7pepUF',\n//   owner: 'kmM4O08BJB85RbxfQ2nkka9VNO6Czm2Tc_IGQNYCTSXRzOc6W9b...',\n//   tags: [],\n//   target: '1seRanklLU_1VTGkEk7P0xAwMJfA7owA1JHW5KyZKlY',\n//   quantity: '10500000000000',\n//   data: '',\n//   data_size: '0',\n//   data_root: '',\n//   data_tree: [],\n//   reward: '7468335',\n//   signature: 'DnUOYbRSkhI4ZXg5fpYDCwPv8yvM5toAneSx4Jlg0zjIocqPs8giPP...'\n// }\n```\n\n#### Submit a transaction\n\nThe preferred method of submitting a data transaction is to use chunk uploading. This method will allow larger transaction sizes, resuming a transaction upload if it's interrupted and give progress updates while uploading.\n\nSimple example:\n\n```js\n\nlet data = fs.readFileSync('path/to/file.pdf');\n\nlet transaction = await arweave.createTransaction({ data: data }, key);\ntransaction.addTag('Content-Type', 'application/pdf');\n\nawait arweave.transactions.sign(transaction, key);\n\nlet uploader = await arweave.transactions.getUploader(transaction);\n\nwhile (!uploader.isComplete) {\n  await uploader.uploadChunk();\n  console.log(`${uploader.pctComplete}% complete, ${uploader.uploadedChunks}/${uploader.totalChunks}`);\n}\n```\n_**N.B.** The above code has been simplified and ignores potential errors._\n\nYou can also submit transactions using `transactions.post()` which is suitable for small transactions or token transfers:\n\n```js\nlet key = await arweave.wallets.generate();\n\nlet transaction = await arweave.createTransaction({\n    target: '1seRanklLU_1VTGkEk7P0xAwMJfA7owA1JHW5KyZKlY',\n    quantity: arweave.ar.arToWinston('10.5')\n}, key);\n\nawait arweave.transactions.sign(transaction, key);\n\nconst response = await arweave.transactions.post(transaction);\n\nconsole.log(response.status);\n// 200 : not to be confused with getStatus === 200, see note below**\n\n// HTTP response codes (200 - server received the transaction, 4XX - invalid transaction, 5XX - error)\n```\n\n**N.B.** \n_This `200` response does not mean that the transaction has mined & confirmed, and that a txid can be used as if it's immutable._ _It just means that a node has received your transaction._ _See [Get a transaction status](#get-a-transaction-status) for more detail on how to correctly determine that your transaction has been mined & confirmed._ _This also applies to the `uploader` method._\n\n\n##### Chunked uploading advanced options\n\nYou can resume an upload from a saved uploader object, that you have persisted in storage some using \n`JSON.stringify(uploader)` at any stage of the upload. To resume, parse it back into an object and pass it to `getUploader()` along with the transactions data:\n\n```js\n\nlet data = fs.readFileSync('path/to/file.pdf'); // get the same data\nlet resumeObject = JSON.parse(savedUploader); // get uploader object from where you stored it.\n\nlet uploader = await arweave.transactions.getUploader(resumeObject, data);\nwhile (!uploader.isComplete) {\n  await uploader.uploadChunk();\n}\n\n```\n\nWhen resuming the upload, you *must provide the same data* as the original upload. When you serialize the uploader object with `JSON.stringify()` to save it somewhere, it will not include the data.\n\nYou can also resume an upload from just the transaction ID and data, once it has been mined into a block. This can be useful if you didn't save the uploader somewhere but the upload got interrupted. This will re-upload all of the data from the beginning, since we don't know which parts have been uploaded:\n\n```js\n\nlet data = fs.readFileSync('path/to/file.pdf'); // get the same data\nlet resumeTxId = 'mytxid' // a transaction id for a mined transaction that didn't complete the upload.\n\nlet uploader = await arweave.transactions.getUploader(resumeTxId, data);\nwhile (!uploader.isComplete) {\n  await uploader.uploadChunk();\n  console.log(`${uploader.pctComplete}% complete`);\n}\n```\n\n\nalternatively\n\n```js\n// example of tx being accepted and mined, but the network is missing the data\nconst Arweave = require(\"./node/index.js\"); // assumed locally built nodejs target\nconst ArweaveTransaction = require(\"./node/lib/transaction.js\");\nconst fs = require(\"fs\");\n\n// initialize a gateway connection\nconst arweave = Arweave.init({\n  host: \"arweave.net\",\n  port: 443,\n  protocol: \"https\",\n});\n\n// the data that you paid for but is missing in the network\nlet missingData = fs.readFileSync(\n  \"./myfile.mov\"\n);\n\n// get the tx headers from arweave.net/tx/{txid}\nlet txHeaders = require(\"./txheaders.json\");\n\n(async () => {\n  const tx = new ArweaveTransaction.default(txHeaders);\n  let uploader = await arweave.transactions.getUploader(tx, missingData);\n  while (!uploader.isComplete) {\n    await uploader.uploadChunk();\n  }\n})();\n```\n\nThere is also an async iterator interface to chunk uploading, but this method means you'll need to ensure you are using a transpiler and polyfill for the asyncIterator symbol for some environments. (Safari on iOS in particular). This method takes the same arguments for uploading/resuming a transaction as `getUploader()` and just has a slightly shorter syntax:\n\n```js\nfor await (const uploader of arweave.transactions.upload(tx)) {\n  console.log(`${uploader.pctComplete}% Complete`);\n}\n// done.\n```\n\n#### Get a transaction status\n\nRemember: Just like other blockchain-style systems (like Bitcoin and Ethereum), you should always ensure that your transaction has received a number of confirmations in blocks before you assume that the transaction has been fully accepted by the network.\n\n```js\narweave.transactions.getStatus('bNbA3TEQVL60xlgCcqdz4ZPHFZ711cZ3hmkpGttDt_U').then(res => {\n    console.log(res);\n    // {\n    //  status: 200,\n    //  confirmed: {\n    //    block_height: 140151,\n    //    block_indep_hash: 'OR1wue3oBSg3XWvH0GBlauAtAjBICVs2F_8YLYQ3aoAR7q6_3fFeuBOw7d-JTEdR',\n    //    number_of_confirmations: 20\n    //  }\n    //}\n})\n```\n_**N.B.** We strongly advise that you check the status and number of confirmations for a given txid before integrating it elsewhere (for example, if you plan to integrate a txid into an NFT contract), even if you have received a ‘200’ status response._\n\n\n#### Get a transaction\n\nFetch a transaction from the connected arweave node. The data and tags are base64 encoded, these can be decoded using the built in helper methods.\n\n**Update since v1.9.0** \n*Due to how the API has evolved over time and with larger transaction support, the `data` field is no longer _guaranteed_ to be returned from the network as part of the transaction json, therefore, it is not recommended that you use this function for fetching data anymore. You should update your applications to use [`arweave.transactions.getData()`](#get-transaction-data) instead, this will handle small transactions, as well as the reassembling of chunks for larger ones, it can also benefit from gateway optimisations.*\n\n```js\nconst transaction = arweave.transactions.get('hKMMPNh_emBf8v_at1tFzNYACisyMQNcKzeeE1QE9p8').then(transaction => {\n  console.log(transaction);\n    // Transaction {\n    //   'format': 1,\n    //   'id': 'hKMMPNh_emBf8v_at1tFzNYACisyMQNcKzeeE1QE9p8',\n    //   'last_tx': 'GW7p6NoGJ495tAoUjU5GLxIH52gqOgk5j78gQv3j0ebvldAlw6VgIUv_lrMNGI72',\n    //   'owner': 'warLaSbicZm1nx9ucf-_5i91CWgmNOcnFJfyJdloCtsbenBhLrcGH472kKTZyuEAp2lSKlZ0NFCT2r2z-0...',\n    //   'tags': [\n    //     {\n    //       'name': 'QXBwLU5hbWU',\n    //       'value': 'd2VpYm90LXNlYXJjaC13ZWlicw'\n    //     }\n    //   ],\n    //   'target': ',\n    //   'quantity': '0',\n    //   'data': 'iVBORw0KGgoAAAANSUhEUgAAArIAAADGCAYAAAAuVWN-AAAACXBIWXMAAAsSAAA...'\n    //   'data_size': '36795',\n    //   'data_tree': [],\n    //   'data_root': ',\n    //   'reward': '93077980',\n    //   'signature': 'RpohCHVl5vzGlG4R5ybeEuhs556Jv7rWOGaZCT69cpIei_j9b9sAetBlr0...'\n    // }\n});\n```\n\n#### Get transaction data\n\nYou can get the transaction data from a transaction ID without having to get the entire transaction\n\n```js\n// Get the base64url encoded string\narweave.transactions.getData('bNbA3TEQVL60xlgCcqdz4ZPHFZ711cZ3hmkpGttDt_U').then(data => {\n  console.log(data);\n  // CjwhRE9DVFlQRSBodG1sPgo...\n});\n\n// Get the data decoded to a Uint8Array for binary data\narweave.transactions.getData('bNbA3TEQVL60xlgCcqdz4ZPHFZ711cZ3hmkpGttDt_U', {decode: true}).then(data => {\n  console.log(data);\n  // Uint8Array [10, 60, 33, 68, ...]\n});\n\n// Get the data decode as string data\narweave.transactions.getData('bNbA3TEQVL60xlgCcqdz4ZPHFZ711cZ3hmkpGttDt_U', {decode: true, string: true}).then(data => {\n  console.log(data);\n  // <!DOCTYPE HTML>...\n});\n```\n\n#### Decode tags from transactions\n\n```js\nconst transaction = arweave.transactions.get('bNbA3TEQVL60xlgCcqdz4ZPHFZ711cZ3hmkpGttDt_U').then(transaction => {\n\n  transaction.get('tags').forEach(tag => {\n    let key = tag.get('name', {decode: true, string: true});\n    let value = tag.get('value', {decode: true, string: true});\n    console.log(`${key} : ${value}`);\n  });\n  // Content-Type : text/html\n  // User-Agent : ArweaveDeploy/1.1.0\n});\n```\n\n### Blocks\nBlocks are base elements of Arweave's blockweave data structure.\nEach block is linked to two prior blocks: the previous block in the \"chain\" (as with traditional blockchain\nprotocols), and a block from the previous history of the blockchain (the \"recall block\"). Each block contains\na list of zero to many transactions.\n\n\n#### Get a block by indep_hash\nGets block data for given independent hash (see page 63. of [yellow-paper](https://www.arweave.org/yellow-paper.pdf) for details).\n\n```js\nconst result = await arweave.blocks.get(\"zbUPQFA4ybnd8h99KI9Iqh4mogXJibr0syEwuJPrFHhOhld7XBMOUDeXfsIGvYDp\"); \nconsole.log(result)\n// {\n//   \"nonce\": \"6jdzO4FzS4EVaQVcLBEmxm6uN5-1tqBXW24Pzp6JsRQ\",\n//   \"previous_block\": \"iNgEv6vf9nIrxLWeEu-vPNHFftEh0kfOnx0qd6NKUOc8Z3WeMeOmAmdOHwSUFAGn\",\n//   \"timestamp\": 1624183433,\n//   \"last_retarget\": 1624183433,\n//   \"diff\": \"115792089220940710686296942055695413965527953310049630981189590430430626054144\",\n//   \"height\": 711150,\n//   \"hash\": \"_____8V8BkM8Cyja5ZFJcc7HfX33eM4BKDAvcEBn22s\",\n//   \"indep_hash\": \"zbUPQFA4ybnd8h99KI9Iqh4mogXJibr0syEwuJPrFHhOhld7XBMOUDeXfsIGvYDp\",\n//   \"txs\": [ ...\n```\n\n#### Get current block\nGets a block data for current block, i.e., block with indep_hash:\n```js\nconst {current} = await arweave.network.getInfo();\n```\n\n```js\nconst result = await arweave.blocks.getCurrent(); \nconsole.log(result)\n// {\n//   \"indep_hash\": \"qoJwHSpzl6Ouo140HW2DTv1rGOrgfBEnHi5sHv-fJt_TsK7xA70F2QbjMCopLiMd\",\n//   ...\n```\n\n### GraphQL \nFind your transation ids and tags by searching their metadata. GraphQL (GQL) provides flexible querying and allows you to search for transactions by tags, wallet address, block height, etc. \n\nPlease see the [GQL Guide](https://gql-guide.vercel.app/) for further details.\n\n\n\n### License\n\nThis software is released under MIT license. See [LICENSE.md](./LICENSE.md) for full license details.\n","readmeFilename":"README.md"}