{"id":18557991,"url":"https://github.com/zh/near-paper","last_synced_at":"2025-05-15T14:30:53.977Z","repository":{"id":51197716,"uuid":"368942386","full_name":"zh/near-paper","owner":"zh","description":"NEAR Paper Wallet","archived":false,"fork":false,"pushed_at":"2021-05-26T11:57:11.000Z","size":14,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-05-05T06:07:27.597Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-05-19T17:00:31.000Z","updated_at":"2021-05-28T22:00:39.000Z","dependencies_parsed_at":"2022-09-16T03:51:59.008Z","dependency_job_id":null,"html_url":"https://github.com/zh/near-paper","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zh%2Fnear-paper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zh%2Fnear-paper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zh%2Fnear-paper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zh%2Fnear-paper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zh","download_url":"https://codeload.github.com/zh/near-paper/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254358545,"owners_count":22057938,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-06T21:38:36.861Z","updated_at":"2025-05-15T14:30:53.928Z","avatar_url":"https://github.com/zh.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NEAR Paper Wallet\n\nBased on [proposal in NEAR forums](https://gov.near.org/t/1843).\n\nPaper Wallets are great way to onboard new users.\nThey are also a great way to save funds off-chain (cold storage).\n\nTechnically it is not a difficult task - just two QR codes with public and private key. However some sweeping functionality need to be added to the real wallets.\n\nIn case of NEAR wallet **account name** also need to be provided. Something as *paper-xxx.somebody.testnet*, where *somebody.testnet* is the parent account, which will create and initially fund the wallet.\n\n## Used libraries and services\n\n- [near-api-js](https://github.com/near/near-api-js) - A JavaScript/TypeScript library for development of DApps on the NEAR platform\n- [bn.js](https://github.com/indutny/bn.js/) - BigNum in pure javascript\n- [js-sha256](https://github.com/emn178/js-sha256) - A simple SHA-256 / SHA-224 hash function for JavaScript supports UTF-8 encoding\n\n## Installation\n\n```sh\ngit clone https://github.com/zh/near-paper\ncd near-paper\nnpm install\n```\n\n* [TODO] for browser\n\n```html\n\u003cscript src=\"https://unpkg.com/near-paper\"\u003e\u003c/script\u003e\n```\n\n## Usage\n\nAll provided examples are requiring parent account name (**sender** - the account, which will create the wallet) and network (**testnet** or **mainnet**). The easiest place to set them is in the `.env` file in the same directory. File format:\n\n```\nNETWORK=testnet\nSENDER=somebody.testnet\n```\n\nAlso there is need from **access keys** (created for example with [near login](https://github.com/near/near-cli#near-login)). For more information see also [access keys NEAR documentation](https://github.com/near/near-cli#near-login).\n\nThe [example/utils.js](examples/utils.js) file provides example for using local file key store.\n\u003e TODO: browser local storage as key store example.\n\n```js\nconst NearPaperWallet = require('near-paper');\nconst AMOUNT = '1.5'\nconst RECEIVER = 'somebody.testnet'\n\nasync function paperWalletTests(sender, amount) {\n  try {\n    const keyStore = ... // provide key store here\n    const wallet = new NearPaperWallet(process.env.SENDER, keyStore);\n\n    // create wallet with 1.5 NEAR initial amount\n    await wallet.create(AMOUNT);\n    wallet.save();\n    console.log(JSON.stringify(wallet, null, 2));\n\n    // sweep all funds\n    // wallet.load('--put-correct-name-here--')\n    const result = await wallet.sweep(RECEIVER);\n    console.log('Transaction Results: ', result.transaction);\n\n    // delete the wallet\n    await wallet.delete();\n\n  } catch (error) {\n    console.error('error in paperWalletTests: ', error);\n  }\n}\n\npaperWalletTests();\n```\n\nYou can see more usage examples in the [examples directory](examples/).\n\n## Example session\n\n### Create wallet\n\n```\n$ node ./examples/create-wallet.js -h\nOptions:\n  -a, --amount   Amount of NEAR to put in the wallet                    [number]\n```\n\nCreate NEAR paper wallet with 2 NEAR initial amount\n\n```\n$ node ./examples/create-wallet.js -a 2\n{\n  \"sender\": \"devops.testnet\",\n  \"networkId\": \"testnet\",\n  \"accountId\": \"paper-1621445075752.devops.testnet\",\n  \"privateKey\": \"41AsYv...\",\n  \"onBlockchain\": true,\n  \"keyStore\": {\n    \"keyDir\": \"/Users/stoyan/.near-credentials\"\n  }\n}\nwallet paper-1621445075752.devops.testnet saved successfully.\n```\n\nThis will also create JSON file in the root directory with name *paper-1621445075752.devops.testnet.json* and content:\n\n```json\n{\n  \"accountId\": \"paper-1621445075752.devops.testnet\",\n  \"privateKey\": \"41AsYv...\",\n  \"onBlockchain\": true\n}\n```\n\nThe example will also show a QR code with link like `https://wallet.testnet.near.org/send-money/{paper_wallet_name}` on the console. You can fund the wallet by scanning the QR code. It will redirect you to the web wallet site as a usual 'Receive' QR code.\n\n### Sweep all funds from the paper wallet\n\n**receiver** is the account name to receive the funds.\n\n```\n$ node ./examples/sweep-wallet.js -h\nOptions:\n  -r, --receiver  Account to get sweeped tokens                         [string]\n  -w, --wallet    Paper wallet name                                     [string]\n```\n\n```\n$ node ./examples/sweep-wallet.js -r devops.testnet -w paper-1621445075752.devops.testnet\nbalance: \"1981800000000000000000000\"\nTransaction Results:  {\n  signer_id: 'paper-1621445075752.devops.testnet',\n  public_key: 'ed25519:F6ENP...',\n  nonce: 48275784000001,\n  receiver_id: 'devops.testnet',\n  actions: [ { Transfer: [Object] } ],\n  signature: 'ed25519:3qEP...',\n  hash: 'a8Vt43dU78HjPKbuF6F6XAQ7JBNS5KMNDc5CE98f3ya'\n}\nhttps://explorer.testnet.near.org/transactions/a8Vt43dU78HjPKbuF6F6XAQ7JBNS5KMNDc5CE98f3ya\n```\n\n\u003e TODO: This need to be added to some real wallet. Not sure also what to contain the QR code: maybe something like `{paper_wallet_name}:{private_key}`: read the QR code; parse it to get name and key and sweep the funds\n\n### Delete the paper wallet\n\nPaper wallets can be reused as many times as needed or can be deleted.\n\n```\n$ node ./examples/delete-wallet.js -h\nOptions:\n  -w, --wallet   Paper wallet name                                      [string]\n```\n\n```\n$ node ./examples/delete-wallet.js -w paper-1621445075752\n```\n\nThis will modify the wallet JSON file with `\"onBlockchain\": false`.\n\n## TODO\n\n* More flexible credentials handling\n* Create JS npm package\n* Create QR codes in addition to JSON file\n* Sweep module for some wallet\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzh%2Fnear-paper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzh%2Fnear-paper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzh%2Fnear-paper/lists"}