项目作者: UsingBlockchain

项目描述 :
Open Standard for the issuance of Securities using blockchain technology (Symbol from NEM)
高级语言: HTML
项目地址: git://github.com/UsingBlockchain/symbol-token-standards.git
创建时间: 2021-02-06T18:01:26Z
项目社区:https://github.com/UsingBlockchain/symbol-token-standards

开源协议:Apache License 2.0

下载


symbol-token-standards

npm version
Build Status
Slack

The author of this package cannot be held responsible for any loss of money or any malintentioned usage forms of this package. Please use this package with caution.

Symbol Token Standards library to create security tokens / financial instruments for the Symbol platform.

This is a PoC to validate the proposed NIP13 - Security Token Standard. When stable, the repository will be moved to the nemtech organization.

Installation

npm install symbol-token-standards

Example Library Usage

:warning: The following example usage for the symbol-token-standards library is subject to change.

  1. import { AggregateTransaction, PublicAccount, SignedTransaction } from 'symbol-sdk'
  2. import { MnemonicPassPhrase } from 'symbol-hd-wallets'
  3. import { NIP13, NetworkConfig, TransactionParameters } from 'symbol-token-standards'
  4. import { TransactionURI } from 'symbol-uri-scheme'
  5. // :warning: The following settings are network specific and may need changes
  6. const transactionParams = new TransactionParameters(
  7. Deadline.create(),
  8. 750000, // maxFee
  9. )
  10. // :warning: You should create separate backups of
  11. // authorities and security token pass phrases.
  12. const authKeys = MnemonicPassPhrase.createRandom() // backup the resulting 24-words safely!
  13. const tokenKeys = MnemonicPassPhrase.createRandom() // backup the resulting 24-words safely!
  14. // :warning: It is recommended to create operator
  15. // keys offline and using a separate device.
  16. const operators = [
  17. new PublicAccount('PUBLIC_KEY_OPERATOR_1', 'ADDRESS_OPERATOR_1'),
  18. new PublicAccount('PUBLIC_KEY_OPERATOR_2', 'ADDRESS_OPERATOR_2'),
  19. // ...
  20. ]
  21. // initialize NIP13 library
  22. const network = new NetworkConfig(...)
  23. const tokenAuthority = new NIP13.TokenAuthority(network, authKeys)
  24. const securityToken = new NIP13.Token(network, tokenKeys)
  25. // offline creation of the `CreateToken` security token contract
  26. const metadata = new SecuritiesMetadata(
  27. 'MIC',
  28. 'ISIN',
  29. 'ISO_10962',
  30. 'Website',
  31. 'Sector',
  32. 'Industry',
  33. {
  34. 'customKey1': 'metadata',
  35. // ...
  36. },
  37. )
  38. const tokenId = securityToken.create(
  39. 'My Awesome Security Token', // security token name
  40. securityToken.getTarget().publicAccount, // actor
  41. tokenAuthority.getAuthority().publicAccount, // token authority
  42. operators,
  43. 123456789, // total outstanding shares
  44. metadata,
  45. transactionParams,
  46. )
  47. // get the transaction URI for `CreateToken` execution
  48. const resultURI: TransactionURI = securityToken.result
  49. // :warning: It is recommended to sign the resulting transactions
  50. // using a hardware wallet rather than any type of software generated
  51. // wallets.
  52. const transaction: AggregateTransaction = resultURI.toTransaction()
  53. const signedTransaction: SignedTransaction = securityToken.getTarget().sign(transaction, 'networkGenerationHash')
  54. // `signedTransaction` can now be broadcast to the Symbol network of choice.
  55. // It is important to denote that given the **aggregate** nature of security
  56. // token contracts, multiple parties MAY be involved in the transaction and
  57. // it is therefor required to issue a HashLockTransaction before announcing
  58. // the aggregate bonded transaction that represents the contract.

License

Copyright 2020-present NEM

Licensed under the Apache v2.0 License.