{"_id":"@apsiocoin/apsio-transactions","_rev":"1-fd7d4b8031bd38edb3c2a3330447b9b0","name":"@apsiocoin/apsio-transactions","dist-tags":{"latest":"0.0.1"},"versions":{"0.0.1":{"name":"@apsiocoin/apsio-transactions","version":"0.0.1","description":"Build and sign(multi-sign) transactions for Apsio blockchain.","keywords":["apsio","crypto","transactions","protocol","binary","cryptography","signature"],"main":"dist/index.js","types":"dist/index.d.ts","scripts":{"preversion":"npm run build","postversion":"npm publish","build-docs":"typedoc --out docs src && cd docs && touch .nojekyll","postpublish":"git push origin head","build":"ts-node build/build.ts && webpack --config webpack.config.js --env","fix-style":"tslint --fix -c tslint.json '{src,test,usage}/**/*{.ts,.tsx}'","test":"jest"},"author":{"name":"apsiocoin"},"contributors":[{"name":"Saysset Nicolas","email":"nicolassaysset@free.fr"},{"name":"Gireaud Luc","email":"luc.gireaud@gmail.com"}],"license":"MIT","devDependencies":{"@types/axios":"^0.14.0","@types/jest":"^23.3.9","@types/long":"^4.0.0","@types/node":"^10.12.3","copy-webpack-plugin":"^4.5.2","jest":"^24.7.1","jsdoc-to-markdown":"^5.0.0","nativescript-typedoc-theme":"0.0.7","ncp":"^2.0.0","preprocess":"^3.1.0","rimraf":"^2.6.2","terser-webpack-plugin":"^1.2.3","ts-jest":"^24.0.2","ts-jsdoc":"^3.0.1","ts-loader":"^5.3.3","ts-node":"^7.0.1","tslint":"^5.20.1","typed-ts-events":"^1.1.1","typedoc":"^0.19.2","typedoc-clarity-theme":"^1.1.0","typedoc-plugin-external-module-name":"^2.1.0","typescript":"^3.7.2","typescript-json-schema":"^0.43.0","webpack":"^4.30.0","webpack-cli":"^3.1.0"},"repository":{"type":"git","url":"git+https://github.com/Nicolas82/apsio-transactions.git"},"dependencies":{"@waves/marshall":"^0.14.0","@waves/node-api-js":"^1.2.3","@waves/protobuf-serialization":"1.4.1-beta.1","@waves/ts-lib-crypto":"1.4.3","@waves/ts-types":"1.0.6-beta.4","axios":"^0.19.0","long":"^4.0.0"},"gitHead":"3f560d98912704dd5b4cd07f0d89d94b1717b190","bugs":{"url":"https://github.com/Nicolas82/apsio-transactions/issues"},"homepage":"https://github.com/Nicolas82/apsio-transactions#readme","_id":"@apsiocoin/apsio-transactions@0.0.1","_nodeVersion":"16.13.2","_npmVersion":"8.1.2","dist":{"integrity":"sha512-A4yseZueBVECiOD/csRIf4aF2yc7donCbOJA81MEjJHVvlWEG3oVtZ4tjChHS4bUEUenNsW8+2QXeLd3KU97Mg==","shasum":"c48d28295660f1e13d9c0e3142d852d25706b86b","tarball":"https://registry.npmjs.org/@apsiocoin/apsio-transactions/-/apsio-transactions-0.0.1.tgz","fileCount":219,"unpackedSize":1006420,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiRCZNACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmqg/g/+MRcW48ocfru5l1hVnMuEB8ogTbbPYIYYACcSxE6YqpGLSSJW\r\nndJPDctA8G9cln4xtp5iFUecTm6g3rDbKOYSddS6VKbS0Av9GuTlBdw2xbr4\r\nEaqE42i0lpZ/hgJpof1ffvACqHc+Od0rr4k9+grhn0xeESmLkIqKU3iNtrz1\r\nyDk+usjamsnxtr3X3JW2qmBEtZJDUl35hO4m5/oaSbMVTReS/wHejmlahANJ\r\nxDV3bKzeNH3YLK9yFUAzYFAn0/VdKg66e5fp6jaiGiGB7eVGpuDRPu12hn2A\r\n9UnxqR0q/MU7lwM+PFsX/loydxvS2613EHTHaPinO5KQwgYnuUKgYjMWAVW2\r\nPKHBnz7nceU0yuPdiGt0TfLlaYbcDA7zQKV4Pyx35n18KYCvjoxA8cOnOI6x\r\nZEc/eRewcy/6Mora740o4lIFYXdARQD+WjPRmCAOIUGfPybG44oBrfx0uHHz\r\nAL64raZ384B6W5FXd4hlruUQ8nbFvpAuA58jT2b29RV+NfUNfe2HPd/BuFOk\r\nv82APwzWCHGwYmVvt4iHVI2yT3bAOu4kb12QLOWcswKhJb3rWKJ+7p0mTDqW\r\nGszcnVaqu+WiLxWQAZ9IfwPbMcbzDUkXuBVPqTYw39onCcfxe2Sj4uCNUqvW\r\nfm2K+Y++CfMczdx8AW0wuy9JsCqNQaHqFkI=\r\n=Syr+\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCrI8vStWT9E2xiq3fXh41dA907I4nwZ5ngnazPHXBwggIhAIn3wlgVHj8yKgnN12SgfdB4y1dt7mqQcCr9l6kIomKB"}]},"_npmUser":{"name":"pythou","email":"nicolassaysset@free.fr"},"directories":{},"maintainers":[{"name":"pythou","email":"nicolassaysset@free.fr"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/apsio-transactions_0.0.1_1648633420961_0.46124513551971646"},"_hasShrinkwrap":false}},"time":{"created":"2022-03-30T09:43:40.916Z","0.0.1":"2022-03-30T09:43:41.194Z","modified":"2022-04-04T15:08:26.294Z"},"maintainers":[{"name":"pythou","email":"nicolassaysset@free.fr"}],"description":"Build and sign(multi-sign) transactions for Apsio blockchain.","homepage":"https://github.com/Nicolas82/apsio-transactions#readme","keywords":["apsio","crypto","transactions","protocol","binary","cryptography","signature"],"repository":{"type":"git","url":"git+https://github.com/Nicolas82/apsio-transactions.git"},"contributors":[{"name":"Saysset Nicolas","email":"nicolassaysset@free.fr"},{"name":"Gireaud Luc","email":"luc.gireaud@gmail.com"}],"author":{"name":"apsiocoin"},"bugs":{"url":"https://github.com/Nicolas82/apsio-transactions/issues"},"license":"MIT","readme":"# waves-transactions  [![npm version](https://badge.fury.io/js/%40waves%2Fwaves-transactions.svg)](https://badge.fury.io/js/%40waves%2Fwaves-transactions)\n\n[![License][license-image]][license-url]\n\n[license-url]: https://opensource.org/licenses/MIT\n[license-image]: https://img.shields.io/npm/l/make-coverage-badge.svg\n\nUsing this library you can easily create and sign transactions for Apsio blockchain.\nIt also allows you to multi-sign existing transactions or create them without signature at all.\n\n- [Transactions](#Transactions) \n  - [Creation](#Creation)\n  - [Signing](#Signing)\n  - [Params](#Params)\n- [Orders](#Orders)\n- [Broadcast](#Broadcast)\n- [Dependencies](#Dependencies)\n## Transactions\n\n### Creation\n\nTransactions are created via transaction creating functions. There are 15 of them:\n```typescript\nconst {\n alias, burn, cancelLease, data, exchange,\n invokeScript, issue, lease, massTransfer, reissue,\n setAssetScript, setScript, sponsorship, transfer, updateAssetInfo\n} = require('@apsiocoin/apsio-transactions')\n```\nExample:\n```typescript\nconst issueTx = issue({\n  name: 'foo',\n  description: 'bar',\n  quantity: 10000,\n  senderPublicKey: 'GucCLYU7aqzcVUwVXX4nosceDisky9UpbmpFK39tVYom',\n  chainId: 'T'\n})\nconst burnTx = burn({\n  assetId: '6toKooURvF3CpRQV8hzhNbHjK3Rb3L9Krd7TFnzcoe8L',\n  senderPublicKey: 'GucCLYU7aqzcVUwVXX4nosceDisky9UpbmpFK39tVYom',\n  chainId: 'T'\n})\n```\n### Signing\nYou can provide seed or private key to transaction creating function to sign it. If you do, senderPublicKey can be omitted.\n```typescript\nconst signedTranfer = transfer({\n    recipient:'3N4mLCaHq2twRKnbUjdvAHyXjoccQE9KDRE',\n    amount: 100000}, 'secret seed phraze'\n)\nconst signedTranferViaPrivateKey = transfer({\n    recipient:'3N4mLCaHq2twRKnbUjdvAHyXjoccQE9KDRE',\n    amount: 100000}, {privateKey: 'GucCLYU7aqzcVUwVXX4nosceDisky9UpbmpFK39tVYom'}\n)\n```\n\n### Params\nType LONG represents string or number. Strings are allowed since max js int is 2**53\n#### Common params:\nPresent in all transactions\n```typescript\ninterface IBasicParams<LONG = string | number> {\n  /**\n   * Transaction fee. If not set, fee will be calculated automatically\n   */\n  fee?: LONG\n  /**\n   * If fee is not set, this value will be added to automatically calculated fee. E.x.:\n   * Account is scripted and 400000 fee more is required.\n   */\n  additionalFee?: number\n  /**\n   * If not set, public key will be derived from seed phrase. You should provide senderPublicKey in two cases:\n   * 1. Account, from which this tx should be sent, differs from tx signer. E.g., we have smart account that requires 2 signatures.\n   * 2. You to create tx without proof. Therefore no seed is provided.\n   */\n  senderPublicKey?: string\n  /**\n   * Transaction timestamp. If not set current timestamp will be used. Date.now()\n   */\n  timestamp?: number\n  /**\n   * Network byte. Could be set as number or as char.\n   * If set as char(string), charCodeAt(0) will be used. E.g.,\n   * 'W' will be converted to '87'\n   * If not set, 87 will be used as default\n   */\n  chainId?: string | number\n}\n```\n\n#### Issue transaction. Type 3\n```typescript\nexport interface IIssueParams<LONG = string | number> extends IBasicParams<LONG> {\n  name: string\n  description: string\n  quantity: LONG\n  decimals?: number\n  reissuable?: boolean\n  script?: string\n}\n```\n#### Transfer transaction. Type 4\n```typescript\nexport interface ITransferParams<LONG = string | number> extends IBasicParams<LONG> {\n  /**\n   * Can be either address(base58 encoded 24 byte address) or alias.\n   * Alias should be used like 'alias:{chainId}:{alias}>'. E.g.:\n   * If we have alias 'foo', and we want TESTNET transaction, recipient should be 'alias:T:foo'\n   */\n  recipient: string\n  amount: LONG\n  assetId?: string | null\n  /**\n   * Fee can be paid in custom token if sponsorship has been set for this token\n   */\n  feeAssetId?: string | null\n  /**\n   * Bytearray encoded as base58 string\n   */\n  attachment?: string | TTypedData\n}\n```\n#### Reissue transaction. Type 5\n```typescript\nexport interface IReissueParams<LONG = string | number> extends IBasicParams<LONG> {\n  assetId: string\n  quantity: LONG\n  reissuable: boolean\n}\n```\n#### Burn transaction. Type 6\n```typescript\nexport interface IBurnParams<LONG = string | number> extends IBasicParams<LONG> {\n  assetId: string\n  quantity: LONG\n}\n```\n#### Exchange transaction. Type 7\nExchange transactions are used by DEX mather. If you want to create your own exchange transaction,\n there is no params. You need to construct it by hand(see interface below, IOrder is described in Order section) \n```typescript\nexport interface IExchangeTransaction<LONG = string | number> extends ITransaction<LONG> {\n  type: 7\n  order1: IOrder\n  order2: IOrder\n  price: LONG\n  amount: LONG\n  buyMatcherFee: LONG\n  sellMatcherFee: LONG\n}\n```\n#### Lease transaction. Type 8\n```typescript\nexport interface ILeaseParams<LONG = string | number> extends IBasicParams<LONG> {\n  recipient: string\n  amount: LONG\n}\n```\n#### CancelLease transaction. Type 9\n```typescript\nexport interface ICancelLeaseParams<LONG = string | number> extends IBasicParams<LONG> {\n  leaseId: string\n}\n```\n#### Alias transaction. Type 10\n```typescript\nexport interface IAliasParams<LONG = string | number> extends IBasicParams<LONG> {\n  alias: string\n}\n```\n#### MassTransfer transaction. Type 11\n```typescript\nexport interface IMassTransferParams<LONG = string | number> extends IBasicParams<LONG> {\n  transfers: IMassTransferItem[]\n  /**\n   * Bytearray encoded as base string\n   */\n  attachment?: string | TTypedData\n  assetId?: string | null\n}\n\nexport interface IMassTransferItem<LONG = string | number> {\n  recipient: string\n  amount: LONG\n}\n```\n#### Data transaction. Type 12\n```typescript\nexport interface IDataParams<LONG = string | number> extends IBasicParams<LONG> {\n  data: Array<IBooleanData | IIntegerData | IStringData | IBinaryData| TDeleteRequest>\n}\nexport type TDeleteRequest = {\n  type?: null\n  value?: null\n  key: string\n}\n\nexport interface IBooleanData {\n  key: string\n  type: 'boolean'\n  value: boolean\n}\nexport interface IIntegerData<LONG = string | number> {\n  key: string\n  type: 'integer'\n  value: LONG\n}\nexport interface IStringData {\n  key: string\n  type: 'string'\n  value: string\n}\nexport interface IBinaryData {\n  key: string\n  type: 'binary'\n  value: string\n}\n\n\n```\n#### SetScript transaction. Type 13\n```typescript\nexport interface ISetScriptParams<LONG = string | number> extends IBasicParams<LONG> {\n  /**\n   * Compiled script encoded as base64 string\n   */\n  script: string | null\n}\n```\n#### Sponsorship transaction. Type 14\n```typescript\nexport interface ISponsorshipParams<LONG = string | number> extends IBasicParams<LONG> {\n  /**\n   * AssetID of sponsored token\n   */\n  assetId: string\n  /**\n   * Minimal fee amount in sponsored asset. To disable sponsorship set it to 0\n   */\n  minSponsoredAssetFee: LONG\n}\n```\n#### SetAssetScript transaction. Type 15\n```typescript\nexport interface ISetAssetScriptParams<LONG = string | number> extends IBasicParams<LONG> {\n  /**\n   * Compiled script encoded as base64 string\n   */\n  script: string\n  assetId: string\n}\n```\n#### InvokeScript transaction. Type 16\n```typescript\nexport interface IInvokeScriptParams<LONG = string | number> extends IBasicParams<LONG> {\n  dApp: string\n  feeAssetId?: string | null\n  call?: {\n    function: string\n    args?: {\n      type: 'binary' | 'integer' | 'boolean' | 'string',\n      value: string | LONG | boolean\n    }[]\n  },\n  payment?: {\n    assetId?: string | null\n    amount: LONG\n  }[]\n}\n```\n#### UpdateAssetInfo transaction. Type 17\n```typescript\nexport interface IUpdateAssetInfoParams<LONG = string | number> extends IBasicParams<LONG> {\n  /**\n   * Id of previously issued asset\n   */\n  assetId: string\n  /**\n   * New asset name\n   */\n  name: string\n  /**\n   * New asset description\n   */\n  description: string\n}\n```\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nIf you want to create  the minimum you need to provide is **amount** and **recipient** as defined in Transfer params:\n```js\n\nconst { transfer } = require('@apsiocoin/apsio-transactions')\nconst seed = 'some example seed phrase'\nconst signedTranserTx = transfer({ \n  amount: 1,\n  recipient: '3N4mLCaHq2twRKnbUjdvAHyXjoccQE9KDRE',\n  //Timestamp is optional but it was overrided, in case timestamp is not provided it will fallback to Date.now(). You can set any oftional params yourself. go check full docs\n  timestamp: 1536917842558 \n}, seed)\n\n// or using alias\n\nconst signedTranserTx = transfer({ \n  amount: 1,\n  recipient: 'alias:W:aliasForMyAddress'\n}, seed)\n```\n\nOutput will be a signed transfer transaction:\n```js\n{\n  id: '8NrUwgKRCMFbUbqXKQAHkGnspmWHEjKUSi5opEC6Havq',\n  type: 4,\n  version: 2,\n  recipient: '3N4mLCaHq2twRKnbUjdvAHyXjoccQE9KDRE',\n  attachment: undefined,\n  feeAssetId: undefined,\n  assetId: undefined,\n  amount: 1,\n  fee: 100000,\n  senderPublicKey: '6nR7CXVV7Zmt9ew11BsNzSvVmuyM5PF6VPbWHW9BHgPq',\n  timestamp: 1536917842558,\n  proofs: [\n    '25kyX6HGjS3rkPTJRj5NVH6LLuZe6SzCzFtoJ8GDkojY9U5oPfVrnwBgrCHXZicfsmLthPUjTrfT9TQL2ciYrPGE'\n  ]\n}\n```\n\nYou can also create transaction, but not sign it:\n```javascript\nconst unsignedTransferTx = transfer({ \n  amount: 1,\n  recipient: '3N4mLCaHq2twRKnbUjdvAHyXjoccQE9KDRE',\n  //senderPublicKey is required if you omit seed\n  senderPublicKey: '6nR7CXVV7Zmt9ew11BsNzSvVmuyM5PF6VPbWHW9BHgPq' \n})\n```\n\nNow you are able to POST it to APSIO API or store for future purpose or you can add another signature from other party:\n```js\nconst otherPartySeed = 'other party seed phrase'\nconst transferSignedWithTwoParties = transfer(signedTranserTx, seed)\n```\n\nSo now there are two proofs:\n```js\n{\n  id: '8NrUwgKRCMFbUbqXKQAHkGnspmWHEjKUSi5opEC6Havq',\n  type: 4,\n  version: 2,\n  recipient: '3N4mLCaHq2twRKnbUjdvAHyXjoccQE9KDRE',\n  attachment: undefined,\n  feeAssetId: undefined,\n  assetId: undefined,\n  amount: 1,\n  fee: 100000,\n  senderPublicKey: '6nR7CXVV7Zmt9ew11BsNzSvVmuyM5PF6VPbWHW9BHgPq',\n  timestamp: 1536917842558,\n  proofs: [\n    '25kyX6HGjS3rkPTJRj5NVH6LLuZe6SzCzFtoJ8GDkojY9U5oPfVrnwBgrCHXZicfsmLthPUjTrfT9TQL2ciYrPGE',\n    'CM9emPzpe6Ram7ZxcYax6s7Hkw6698wXCMPSckveFAS2Yh9vqJpy1X9nL7p4RKgU3UEa8c9RGXfUK6mFFq4dL9z'\n  ]\n}\n```\n\n### Orders\nOrder is created the same way as transaction\n```typescript\nconst { order } = require('@apsiocoin/apsio-transactions')\nconst params = {\n    amount: 100000000, //1 waves\n    price: 10, //for 0.00000010 BTC\n    priceAsset: '8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS',\n    matcherPublicKey: '7kPFrHDiGw1rCm7LPszuECwWYL3dMf6iMifLRDJQZMzy',\n    orderType: 'buy'\n}\n  \nconst signedOrder = order(params, 'Some seed ')\n```\n### Broadcast\nTo send transaction you can use either node [REST API](https://nodes.wavesplatform.com/api-docs/index.html#!/transactions/broadcast) or [broadcast](https://wavesplatform.github.io/waves-transactions/globals.html#broadcast) helper function:\n```javascript\nconst {broadcast} =  require('@apsiocoin/apsio-transactions');\nconst nodeUrl = 'https://nodes.wavesplatform.com';\n\nbroadcast(signedTx, nodeUrl).then(resp => console.log(resp))\n```\nYou can send tx to any waves node you like:. E.g.:\n* https://nodes-testnet.wavesnodes.com - waves TESTNET nodes hosted by Wavesplatform\n* https://nodes.wavesplatform.com - waves MAINNET nodes hosted by Wavesplatform\n#### Important!!!\nMost transactions require chainId as parameter, e.g: [IBurnParams](https://wavesplatform.github.io/waves-transactions/interfaces/_transactions_.iburnparams.html). By default chainId is 'W', which means MAINNET. To make transaction in TESTNET be sure to pass chainId if it is present in params interface and then send it to TESTNET node\n\n### Dependencies\nThis library uses `@waves/ts-lib-crypto` for cryptography and `@waves/node-api-js` for interacting with node. \nYou can access them this way:\n```typescript\nconst libCrypto = require('@apsiocoin/apsio-transactions').libs.crypto\nconst libApi = require('@apsiocoin/apsio-transactions').libs.nodeApiJs\n```\n","readmeFilename":"README.md"}