phantasma-sdk-ts 0.1.71
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintignore +13 -0
- package/.eslintrc.cjs +15 -0
- package/.github/workflows/npm-publish.yml +47 -0
- package/.prettierignore +13 -0
- package/.prettierrc +8 -0
- package/LICENSE +201 -0
- package/README.md +842 -0
- package/babel.config.js +6 -0
- package/core/index.d.ts +10 -0
- package/core/index.d.ts.map +1 -0
- package/core/index.js +25 -0
- package/core/interfaces/IContract.d.ts +27 -0
- package/core/interfaces/IContract.d.ts.map +1 -0
- package/core/interfaces/IContract.js +25 -0
- package/core/interfaces/IKeyPair.d.ts +7 -0
- package/core/interfaces/IKeyPair.d.ts.map +1 -0
- package/core/interfaces/IKeyPair.js +2 -0
- package/core/interfaces/ISerializable.d.ts +6 -0
- package/core/interfaces/ISerializable.d.ts.map +1 -0
- package/core/interfaces/ISerializable.js +9 -0
- package/core/interfaces/IStack.d.ts +7 -0
- package/core/interfaces/IStack.d.ts.map +1 -0
- package/core/interfaces/IStack.js +2 -0
- package/core/interfaces/IToken.d.ts +29 -0
- package/core/interfaces/IToken.d.ts.map +1 -0
- package/core/interfaces/IToken.js +22 -0
- package/core/interfaces/Signature.d.ts +21 -0
- package/core/interfaces/Signature.d.ts.map +1 -0
- package/core/interfaces/Signature.js +31 -0
- package/core/interfaces/index.d.ts +7 -0
- package/core/interfaces/index.d.ts.map +1 -0
- package/core/interfaces/index.js +22 -0
- package/core/ledger/Address-Transcode.d.ts +20 -0
- package/core/ledger/Address-Transcode.d.ts.map +1 -0
- package/core/ledger/Address-Transcode.js +70 -0
- package/core/ledger/Ledger-Commands.d.ts +76 -0
- package/core/ledger/Ledger-Commands.d.ts.map +1 -0
- package/core/ledger/Ledger-Commands.js +530 -0
- package/core/ledger/Ledger-Utils.d.ts +74 -0
- package/core/ledger/Ledger-Utils.d.ts.map +1 -0
- package/core/ledger/Ledger-Utils.js +609 -0
- package/core/ledger/LedgerConfig.d.ts +17 -0
- package/core/ledger/LedgerConfig.d.ts.map +1 -0
- package/core/ledger/LedgerConfig.js +2 -0
- package/core/ledger/Mnemonic.d.ts +35 -0
- package/core/ledger/Mnemonic.d.ts.map +1 -0
- package/core/ledger/Mnemonic.js +65 -0
- package/core/ledger/Transaction-Sign.d.ts +10 -0
- package/core/ledger/Transaction-Sign.d.ts.map +1 -0
- package/core/ledger/Transaction-Sign.js +149 -0
- package/core/ledger/Transaction-Transcode.d.ts +24 -0
- package/core/ledger/Transaction-Transcode.d.ts.map +1 -0
- package/core/ledger/Transaction-Transcode.js +47 -0
- package/core/ledger/index.d.ts +9 -0
- package/core/ledger/index.d.ts.map +1 -0
- package/core/ledger/index.js +24 -0
- package/core/ledger/interfaces/ApplicationNameResponse.d.ts +6 -0
- package/core/ledger/interfaces/ApplicationNameResponse.d.ts.map +1 -0
- package/core/ledger/interfaces/ApplicationNameResponse.js +2 -0
- package/core/ledger/interfaces/Device.d.ts +7 -0
- package/core/ledger/interfaces/Device.d.ts.map +1 -0
- package/core/ledger/interfaces/Device.js +2 -0
- package/core/ledger/interfaces/DeviceResponse.d.ts +7 -0
- package/core/ledger/interfaces/DeviceResponse.d.ts.map +1 -0
- package/core/ledger/interfaces/DeviceResponse.js +2 -0
- package/core/ledger/interfaces/Ledger.d.ts +2 -0
- package/core/ledger/interfaces/Ledger.d.ts.map +1 -0
- package/core/ledger/interfaces/Ledger.js +2 -0
- package/core/ledger/interfaces/LedgerBalanceFromLedgerResponse.d.ts +12 -0
- package/core/ledger/interfaces/LedgerBalanceFromLedgerResponse.d.ts.map +1 -0
- package/core/ledger/interfaces/LedgerBalanceFromLedgerResponse.js +2 -0
- package/core/ledger/interfaces/LedgerConfig.d.ts +17 -0
- package/core/ledger/interfaces/LedgerConfig.d.ts.map +1 -0
- package/core/ledger/interfaces/LedgerConfig.js +2 -0
- package/core/ledger/interfaces/LedgerDeviceInfoResponse.d.ts +7 -0
- package/core/ledger/interfaces/LedgerDeviceInfoResponse.d.ts.map +1 -0
- package/core/ledger/interfaces/LedgerDeviceInfoResponse.js +2 -0
- package/core/ledger/interfaces/LedgerSendTransactionResponse.d.ts +5 -0
- package/core/ledger/interfaces/LedgerSendTransactionResponse.d.ts.map +1 -0
- package/core/ledger/interfaces/LedgerSendTransactionResponse.js +2 -0
- package/core/ledger/interfaces/LedgerSigner.d.ts +6 -0
- package/core/ledger/interfaces/LedgerSigner.d.ts.map +1 -0
- package/core/ledger/interfaces/LedgerSigner.js +2 -0
- package/core/ledger/interfaces/LedgerSignerData.d.ts +8 -0
- package/core/ledger/interfaces/LedgerSignerData.d.ts.map +1 -0
- package/core/ledger/interfaces/LedgerSignerData.js +2 -0
- package/core/ledger/interfaces/PublicKeyResponse.d.ts +6 -0
- package/core/ledger/interfaces/PublicKeyResponse.d.ts.map +1 -0
- package/core/ledger/interfaces/PublicKeyResponse.js +2 -0
- package/core/ledger/interfaces/SignResponse.d.ts +6 -0
- package/core/ledger/interfaces/SignResponse.d.ts.map +1 -0
- package/core/ledger/interfaces/SignResponse.js +2 -0
- package/core/ledger/interfaces/VersionResponse.d.ts +6 -0
- package/core/ledger/interfaces/VersionResponse.d.ts.map +1 -0
- package/core/ledger/interfaces/VersionResponse.js +2 -0
- package/core/ledger/interfaces/index.d.ts +14 -0
- package/core/ledger/interfaces/index.d.ts.map +1 -0
- package/core/ledger/interfaces/index.js +29 -0
- package/core/ledger/ledger-comm.d.ts +85 -0
- package/core/ledger/ledger-comm.d.ts.map +1 -0
- package/core/ledger/ledger-comm.js +613 -0
- package/core/link/easyConnect.d.ts +23 -0
- package/core/link/easyConnect.d.ts.map +1 -0
- package/core/link/easyConnect.js +237 -0
- package/core/link/easyScript.d.ts +13 -0
- package/core/link/easyScript.d.ts.map +1 -0
- package/core/link/easyScript.js +52 -0
- package/core/link/index.d.ts +2 -0
- package/core/link/index.d.ts.map +1 -0
- package/core/link/index.js +17 -0
- package/core/link/interfaces/IAccount.d.ts +13 -0
- package/core/link/interfaces/IAccount.d.ts.map +1 -0
- package/core/link/interfaces/IAccount.js +2 -0
- package/core/link/interfaces/IFile.d.ts +7 -0
- package/core/link/interfaces/IFile.d.ts.map +1 -0
- package/core/link/interfaces/IFile.js +2 -0
- package/core/link/interfaces/ProofOfWork.d.ts +9 -0
- package/core/link/interfaces/ProofOfWork.d.ts.map +1 -0
- package/core/link/interfaces/ProofOfWork.js +12 -0
- package/core/link/interfaces/index.d.ts +4 -0
- package/core/link/interfaces/index.d.ts.map +1 -0
- package/core/link/interfaces/index.js +19 -0
- package/core/link/phantasmaLink.d.ts +41 -0
- package/core/link/phantasmaLink.d.ts.map +1 -0
- package/core/link/phantasmaLink.js +479 -0
- package/core/rpc/index.d.ts +3 -0
- package/core/rpc/index.d.ts.map +1 -0
- package/core/rpc/index.js +18 -0
- package/core/rpc/interfaces/ABIContract.d.ts +6 -0
- package/core/rpc/interfaces/ABIContract.d.ts.map +1 -0
- package/core/rpc/interfaces/ABIContract.js +2 -0
- package/core/rpc/interfaces/ABIEvent.d.ts +7 -0
- package/core/rpc/interfaces/ABIEvent.d.ts.map +1 -0
- package/core/rpc/interfaces/ABIEvent.js +2 -0
- package/core/rpc/interfaces/ABIMethod.d.ts +7 -0
- package/core/rpc/interfaces/ABIMethod.d.ts.map +1 -0
- package/core/rpc/interfaces/ABIMethod.js +2 -0
- package/core/rpc/interfaces/ABIParameter.d.ts +5 -0
- package/core/rpc/interfaces/ABIParameter.d.ts.map +1 -0
- package/core/rpc/interfaces/ABIParameter.js +2 -0
- package/core/rpc/interfaces/Account.d.ts +16 -0
- package/core/rpc/interfaces/Account.d.ts.map +1 -0
- package/core/rpc/interfaces/Account.js +2 -0
- package/core/rpc/interfaces/AccountTransactions.d.ts +6 -0
- package/core/rpc/interfaces/AccountTransactions.d.ts.map +1 -0
- package/core/rpc/interfaces/AccountTransactions.js +2 -0
- package/core/rpc/interfaces/Archive.d.ts +11 -0
- package/core/rpc/interfaces/Archive.d.ts.map +1 -0
- package/core/rpc/interfaces/Archive.js +2 -0
- package/core/rpc/interfaces/Auction.d.ts +13 -0
- package/core/rpc/interfaces/Auction.d.ts.map +1 -0
- package/core/rpc/interfaces/Auction.js +2 -0
- package/core/rpc/interfaces/Balance.d.ts +8 -0
- package/core/rpc/interfaces/Balance.d.ts.map +1 -0
- package/core/rpc/interfaces/Balance.js +2 -0
- package/core/rpc/interfaces/Block.d.ts +17 -0
- package/core/rpc/interfaces/Block.d.ts.map +1 -0
- package/core/rpc/interfaces/Block.js +2 -0
- package/core/rpc/interfaces/Chain.d.ts +10 -0
- package/core/rpc/interfaces/Chain.d.ts.map +1 -0
- package/core/rpc/interfaces/Chain.js +2 -0
- package/core/rpc/interfaces/Channel.d.ts +13 -0
- package/core/rpc/interfaces/Channel.d.ts.map +1 -0
- package/core/rpc/interfaces/Channel.js +2 -0
- package/core/rpc/interfaces/Contract.d.ts +11 -0
- package/core/rpc/interfaces/Contract.d.ts.map +1 -0
- package/core/rpc/interfaces/Contract.js +2 -0
- package/core/rpc/interfaces/Dapp.d.ts +6 -0
- package/core/rpc/interfaces/Dapp.d.ts.map +1 -0
- package/core/rpc/interfaces/Dapp.js +2 -0
- package/core/rpc/interfaces/Event.d.ts +7 -0
- package/core/rpc/interfaces/Event.d.ts.map +1 -0
- package/core/rpc/interfaces/Event.js +2 -0
- package/core/rpc/interfaces/Governance.d.ts +5 -0
- package/core/rpc/interfaces/Governance.d.ts.map +1 -0
- package/core/rpc/interfaces/Governance.js +2 -0
- package/core/rpc/interfaces/Interop.d.ts +5 -0
- package/core/rpc/interfaces/Interop.d.ts.map +1 -0
- package/core/rpc/interfaces/Interop.js +2 -0
- package/core/rpc/interfaces/KeyValue.d.ts +5 -0
- package/core/rpc/interfaces/KeyValue.d.ts.map +1 -0
- package/core/rpc/interfaces/KeyValue.js +2 -0
- package/core/rpc/interfaces/Leaderboard.d.ts +6 -0
- package/core/rpc/interfaces/Leaderboard.d.ts.map +1 -0
- package/core/rpc/interfaces/Leaderboard.js +2 -0
- package/core/rpc/interfaces/LeaderboardRow.d.ts +5 -0
- package/core/rpc/interfaces/LeaderboardRow.d.ts.map +1 -0
- package/core/rpc/interfaces/LeaderboardRow.js +2 -0
- package/core/rpc/interfaces/NFT.d.ts +14 -0
- package/core/rpc/interfaces/NFT.d.ts.map +1 -0
- package/core/rpc/interfaces/NFT.js +2 -0
- package/core/rpc/interfaces/Nexus.d.ts +14 -0
- package/core/rpc/interfaces/Nexus.d.ts.map +1 -0
- package/core/rpc/interfaces/Nexus.js +2 -0
- package/core/rpc/interfaces/Oracle.d.ts +5 -0
- package/core/rpc/interfaces/Oracle.d.ts.map +1 -0
- package/core/rpc/interfaces/Oracle.js +2 -0
- package/core/rpc/interfaces/Organization.d.ts +6 -0
- package/core/rpc/interfaces/Organization.d.ts.map +1 -0
- package/core/rpc/interfaces/Organization.js +2 -0
- package/core/rpc/interfaces/Paginated.d.ts +8 -0
- package/core/rpc/interfaces/Paginated.d.ts.map +1 -0
- package/core/rpc/interfaces/Paginated.js +2 -0
- package/core/rpc/interfaces/Peer.d.ts +8 -0
- package/core/rpc/interfaces/Peer.d.ts.map +1 -0
- package/core/rpc/interfaces/Peer.js +2 -0
- package/core/rpc/interfaces/Platform.d.ts +9 -0
- package/core/rpc/interfaces/Platform.d.ts.map +1 -0
- package/core/rpc/interfaces/Platform.js +2 -0
- package/core/rpc/interfaces/Receipt.d.ts +10 -0
- package/core/rpc/interfaces/Receipt.d.ts.map +1 -0
- package/core/rpc/interfaces/Receipt.js +2 -0
- package/core/rpc/interfaces/Script.d.ts +9 -0
- package/core/rpc/interfaces/Script.d.ts.map +1 -0
- package/core/rpc/interfaces/Script.js +2 -0
- package/core/rpc/interfaces/SendRawTx.d.ts +5 -0
- package/core/rpc/interfaces/SendRawTx.d.ts.map +1 -0
- package/core/rpc/interfaces/SendRawTx.js +2 -0
- package/core/rpc/interfaces/SignatureResult.d.ts +5 -0
- package/core/rpc/interfaces/SignatureResult.d.ts.map +1 -0
- package/core/rpc/interfaces/SignatureResult.js +2 -0
- package/core/rpc/interfaces/Stake.d.ts +6 -0
- package/core/rpc/interfaces/Stake.d.ts.map +1 -0
- package/core/rpc/interfaces/Stake.js +2 -0
- package/core/rpc/interfaces/Storage.d.ts +8 -0
- package/core/rpc/interfaces/Storage.d.ts.map +1 -0
- package/core/rpc/interfaces/Storage.js +2 -0
- package/core/rpc/interfaces/Swap.d.ts +13 -0
- package/core/rpc/interfaces/Swap.d.ts.map +1 -0
- package/core/rpc/interfaces/Swap.js +2 -0
- package/core/rpc/interfaces/Token.d.ts +19 -0
- package/core/rpc/interfaces/Token.d.ts.map +1 -0
- package/core/rpc/interfaces/Token.js +2 -0
- package/core/rpc/interfaces/TokenData.d.ts +13 -0
- package/core/rpc/interfaces/TokenData.d.ts.map +1 -0
- package/core/rpc/interfaces/TokenData.js +2 -0
- package/core/rpc/interfaces/TokenExternal.d.ts +5 -0
- package/core/rpc/interfaces/TokenExternal.d.ts.map +1 -0
- package/core/rpc/interfaces/TokenExternal.js +2 -0
- package/core/rpc/interfaces/TokenPrice.d.ts +8 -0
- package/core/rpc/interfaces/TokenPrice.d.ts.map +1 -0
- package/core/rpc/interfaces/TokenPrice.js +2 -0
- package/core/rpc/interfaces/TokenSeries.d.ts +12 -0
- package/core/rpc/interfaces/TokenSeries.d.ts.map +1 -0
- package/core/rpc/interfaces/TokenSeries.js +2 -0
- package/core/rpc/interfaces/TransactionData.d.ts +23 -0
- package/core/rpc/interfaces/TransactionData.d.ts.map +1 -0
- package/core/rpc/interfaces/TransactionData.js +2 -0
- package/core/rpc/interfaces/Validator.d.ts +5 -0
- package/core/rpc/interfaces/Validator.d.ts.map +1 -0
- package/core/rpc/interfaces/Validator.js +2 -0
- package/core/rpc/interfaces/index.d.ts +42 -0
- package/core/rpc/interfaces/index.d.ts.map +1 -0
- package/core/rpc/interfaces/index.js +57 -0
- package/core/rpc/phantasma.d.ts +89 -0
- package/core/rpc/phantasma.d.ts.map +1 -0
- package/core/rpc/phantasma.js +900 -0
- package/core/tx/SignatureKind.js +9 -0
- package/core/tx/Transaction.d.ts +28 -0
- package/core/tx/Transaction.d.ts.map +1 -0
- package/core/tx/Transaction.js +209 -0
- package/core/tx/index.d.ts +3 -0
- package/core/tx/index.d.ts.map +1 -0
- package/core/tx/index.js +18 -0
- package/core/tx/utils.d.ts +10 -0
- package/core/tx/utils.d.ts.map +1 -0
- package/core/tx/utils.js +147 -0
- package/core/types/Address.d.ts +41 -0
- package/core/types/Address.d.ts.map +1 -0
- package/core/types/Address.js +276 -0
- package/core/types/Consensus.d.ts +61 -0
- package/core/types/Consensus.d.ts.map +1 -0
- package/core/types/Consensus.js +151 -0
- package/core/types/Contract.d.ts +60 -0
- package/core/types/Contract.d.ts.map +1 -0
- package/core/types/Contract.js +342 -0
- package/core/types/DomainSettings.d.ts +87 -0
- package/core/types/DomainSettings.d.ts.map +1 -0
- package/core/types/DomainSettings.js +107 -0
- package/core/types/Ed25519Signature.d.ts +16 -0
- package/core/types/Ed25519Signature.d.ts.map +1 -0
- package/core/types/Ed25519Signature.js +78 -0
- package/core/types/Entropy.d.ts +5 -0
- package/core/types/Entropy.d.ts.map +1 -0
- package/core/types/Entropy.js +24 -0
- package/core/types/Extensions/Base16.d.ts +7 -0
- package/core/types/Extensions/Base16.d.ts.map +1 -0
- package/core/types/Extensions/Base16.js +36 -0
- package/core/types/Extensions/BinaryReader.d.ts +17 -0
- package/core/types/Extensions/BinaryReader.d.ts.map +1 -0
- package/core/types/Extensions/BinaryReader.js +192 -0
- package/core/types/Extensions/BinaryWriter.d.ts +25 -0
- package/core/types/Extensions/BinaryWriter.d.ts.map +1 -0
- package/core/types/Extensions/BinaryWriter.js +191 -0
- package/core/types/Extensions/Describer.d.ts +5 -0
- package/core/types/Extensions/Describer.d.ts.map +1 -0
- package/core/types/Extensions/Describer.js +25 -0
- package/core/types/Extensions/PBinaryReader.d.ts +42 -0
- package/core/types/Extensions/PBinaryReader.d.ts.map +1 -0
- package/core/types/Extensions/PBinaryReader.js +269 -0
- package/core/types/Extensions/PBinaryWriter.d.ts +49 -0
- package/core/types/Extensions/PBinaryWriter.d.ts.map +1 -0
- package/core/types/Extensions/PBinaryWriter.js +250 -0
- package/core/types/Extensions/TableColumns.d.ts +5 -0
- package/core/types/Extensions/TableColumns.d.ts.map +1 -0
- package/core/types/Extensions/TableColumns.js +22 -0
- package/core/types/Extensions/index.d.ts +5 -0
- package/core/types/Extensions/index.d.ts.map +1 -0
- package/core/types/Extensions/index.js +20 -0
- package/core/types/PhantasmaKeys.d.ts +19 -0
- package/core/types/PhantasmaKeys.d.ts.map +1 -0
- package/core/types/PhantasmaKeys.js +92 -0
- package/core/types/Serialization.d.ts +22 -0
- package/core/types/Serialization.d.ts.map +1 -0
- package/core/types/Serialization.js +195 -0
- package/core/types/Stack.d.ts +16 -0
- package/core/types/Stack.d.ts.map +1 -0
- package/core/types/Stack.js +42 -0
- package/core/types/Timestamp.d.ts +26 -0
- package/core/types/Timestamp.d.ts.map +1 -0
- package/core/types/Timestamp.js +74 -0
- package/core/types/index.d.ts +12 -0
- package/core/types/index.d.ts.map +1 -0
- package/core/types/index.js +27 -0
- package/core/utils/index.d.ts +25 -0
- package/core/utils/index.d.ts.map +1 -0
- package/core/utils/index.js +236 -0
- package/core/vm/Contracts.d.ts +17 -0
- package/core/vm/Contracts.d.ts.map +1 -0
- package/core/vm/Contracts.js +20 -0
- package/core/vm/Decoder.d.ts +19 -0
- package/core/vm/Decoder.d.ts.map +1 -0
- package/core/vm/Decoder.js +175 -0
- package/core/vm/EventData.d.ts +97 -0
- package/core/vm/EventData.d.ts.map +1 -0
- package/core/vm/EventData.js +134 -0
- package/core/vm/Opcode.d.ts +57 -0
- package/core/vm/Opcode.d.ts.map +1 -0
- package/core/vm/Opcode.js +69 -0
- package/core/vm/ScriptBuilder.d.ts +65 -0
- package/core/vm/ScriptBuilder.d.ts.map +1 -0
- package/core/vm/ScriptBuilder.js +592 -0
- package/core/vm/VMObject.d.ts +55 -0
- package/core/vm/VMObject.d.ts.map +1 -0
- package/core/vm/VMObject.js +1101 -0
- package/core/vm/VMType.d.ts +12 -0
- package/core/vm/VMType.d.ts.map +1 -0
- package/core/vm/VMType.js +15 -0
- package/core/vm/index.d.ts +8 -0
- package/core/vm/index.d.ts.map +1 -0
- package/core/vm/index.js +23 -0
- package/html/TestWebPage.html +187 -0
- package/html/phantasma.js +60504 -0
- package/index.d.ts +5 -0
- package/index.d.ts.map +1 -0
- package/index.js +36 -0
- package/jest.config.js +5 -0
- package/package.json +67 -0
- package/src/core/index.ts +9 -0
- package/src/core/interfaces/IContract.ts +28 -0
- package/src/core/interfaces/IKeyPair.ts +14 -0
- package/src/core/interfaces/ISerializable.ts +6 -0
- package/src/core/interfaces/IStack.ts +6 -0
- package/src/core/interfaces/IToken.ts +31 -0
- package/src/core/interfaces/Signature.ts +32 -0
- package/src/core/interfaces/index.ts +6 -0
- package/src/core/ledger/Address-Transcode.ts +44 -0
- package/src/core/ledger/Ledger-Commands.ts +463 -0
- package/src/core/ledger/Ledger-Utils.ts +549 -0
- package/src/core/ledger/Mnemonic.ts +79 -0
- package/src/core/ledger/Transaction-Sign.ts +126 -0
- package/src/core/ledger/Transaction-Transcode.ts +56 -0
- package/src/core/ledger/index.ts +8 -0
- package/src/core/ledger/interfaces/ApplicationNameResponse.ts +5 -0
- package/src/core/ledger/interfaces/Device.ts +6 -0
- package/src/core/ledger/interfaces/DeviceResponse.ts +6 -0
- package/src/core/ledger/interfaces/Ledger.ts +10 -0
- package/src/core/ledger/interfaces/LedgerBalanceFromLedgerResponse.ts +9 -0
- package/src/core/ledger/interfaces/LedgerConfig.ts +17 -0
- package/src/core/ledger/interfaces/LedgerDeviceInfoResponse.ts +7 -0
- package/src/core/ledger/interfaces/LedgerSendTransactionResponse.ts +4 -0
- package/src/core/ledger/interfaces/LedgerSigner.ts +6 -0
- package/src/core/ledger/interfaces/LedgerSignerData.ts +8 -0
- package/src/core/ledger/interfaces/PublicKeyResponse.ts +5 -0
- package/src/core/ledger/interfaces/SignResponse.ts +5 -0
- package/src/core/ledger/interfaces/VersionResponse.ts +5 -0
- package/src/core/ledger/interfaces/index.ts +13 -0
- package/src/core/link/easyConnect.ts +214 -0
- package/src/core/link/easyScript.ts +67 -0
- package/src/core/link/index.ts +1 -0
- package/src/core/link/interfaces/IAccount.ts +13 -0
- package/src/core/link/interfaces/IFile.ts +6 -0
- package/src/core/link/interfaces/ProofOfWork.ts +8 -0
- package/src/core/link/interfaces/index.ts +3 -0
- package/src/core/link/phantasmaLink.ts +561 -0
- package/src/core/rpc/index.ts +2 -0
- package/src/core/rpc/interfaces/ABIContract.ts +6 -0
- package/src/core/rpc/interfaces/ABIEvent.ts +6 -0
- package/src/core/rpc/interfaces/ABIMethod.ts +7 -0
- package/src/core/rpc/interfaces/ABIParameter.ts +4 -0
- package/src/core/rpc/interfaces/Account.ts +16 -0
- package/src/core/rpc/interfaces/AccountTransactions.ts +6 -0
- package/src/core/rpc/interfaces/Archive.ts +10 -0
- package/src/core/rpc/interfaces/Auction.ts +12 -0
- package/src/core/rpc/interfaces/Balance.ts +7 -0
- package/src/core/rpc/interfaces/Block.ts +17 -0
- package/src/core/rpc/interfaces/Chain.ts +9 -0
- package/src/core/rpc/interfaces/Channel.ts +12 -0
- package/src/core/rpc/interfaces/Contract.ts +11 -0
- package/src/core/rpc/interfaces/Dapp.ts +5 -0
- package/src/core/rpc/interfaces/Event.ts +6 -0
- package/src/core/rpc/interfaces/Governance.ts +4 -0
- package/src/core/rpc/interfaces/Interop.ts +4 -0
- package/src/core/rpc/interfaces/KeyValue.ts +4 -0
- package/src/core/rpc/interfaces/Leaderboard.ts +6 -0
- package/src/core/rpc/interfaces/LeaderboardRow.ts +4 -0
- package/src/core/rpc/interfaces/NFT.ts +14 -0
- package/src/core/rpc/interfaces/Nexus.ts +14 -0
- package/src/core/rpc/interfaces/Oracle.ts +4 -0
- package/src/core/rpc/interfaces/Organization.ts +5 -0
- package/src/core/rpc/interfaces/Paginated.ts +7 -0
- package/src/core/rpc/interfaces/Peer.ts +7 -0
- package/src/core/rpc/interfaces/Platform.ts +9 -0
- package/src/core/rpc/interfaces/Receipt.ts +9 -0
- package/src/core/rpc/interfaces/Script.ts +9 -0
- package/src/core/rpc/interfaces/SendRawTx.ts +4 -0
- package/src/core/rpc/interfaces/SignatureResult.ts +4 -0
- package/src/core/rpc/interfaces/Stake.ts +5 -0
- package/src/core/rpc/interfaces/Storage.ts +8 -0
- package/src/core/rpc/interfaces/Swap.ts +12 -0
- package/src/core/rpc/interfaces/Token.ts +19 -0
- package/src/core/rpc/interfaces/TokenData.ts +12 -0
- package/src/core/rpc/interfaces/TokenExternal.ts +4 -0
- package/src/core/rpc/interfaces/TokenPrice.ts +7 -0
- package/src/core/rpc/interfaces/TokenSeries.ts +12 -0
- package/src/core/rpc/interfaces/TransactionData.ts +23 -0
- package/src/core/rpc/interfaces/Validator.ts +4 -0
- package/src/core/rpc/interfaces/index.ts +41 -0
- package/src/core/rpc/phantasma.ts +466 -0
- package/src/core/tx/Transaction.ts +258 -0
- package/src/core/tx/index.ts +2 -0
- package/src/core/tx/utils.ts +106 -0
- package/src/core/types/Address.ts +290 -0
- package/src/core/types/Consensus.ts +181 -0
- package/src/core/types/Contract.ts +324 -0
- package/src/core/types/DomainSettings.ts +128 -0
- package/src/core/types/Ed25519Signature.ts +78 -0
- package/src/core/types/Entropy.ts +16 -0
- package/src/core/types/Extensions/Base16.ts +36 -0
- package/src/core/types/Extensions/Describer.ts +17 -0
- package/src/core/types/Extensions/PBinaryReader.ts +247 -0
- package/src/core/types/Extensions/PBinaryWriter.ts +278 -0
- package/src/core/types/Extensions/index.ts +4 -0
- package/src/core/types/PhantasmaKeys.ts +119 -0
- package/src/core/types/Serialization.ts +211 -0
- package/src/core/types/Stack.ts +46 -0
- package/src/core/types/Timestamp.ts +93 -0
- package/src/core/types/index.ts +11 -0
- package/src/core/utils/index.ts +206 -0
- package/src/core/vm/Contracts.ts +17 -0
- package/src/core/vm/Decoder.ts +162 -0
- package/src/core/vm/Disassembler.ts +1 -0
- package/src/core/vm/EventData.ts +135 -0
- package/src/core/vm/Opcode.ts +74 -0
- package/src/core/vm/ScriptBuilder.ts +588 -0
- package/src/core/vm/VMObject.ts +1162 -0
- package/src/core/vm/VMType.ts +11 -0
- package/src/core/vm/index.ts +7 -0
- package/src/core/vm/utils/DisasmMethodCall.ts +22 -0
- package/src/core/vm/utils/DisasmUtils.ts +89 -0
- package/src/core/vm/utils/index.ts +2 -0
- package/src/index.ts +7 -0
- package/tests/VMObject.test.ts +146 -0
- package/tests/ledger/Address-Transacode.test.ts +26 -0
- package/tests/tx/Transaction.test.ts +274 -0
- package/tests/types/Address.test.ts +26 -0
- package/tests/types/Consensus.test.ts +67 -0
- package/tsconfig.json +29 -0
package/README.md
ADDED
|
@@ -0,0 +1,842 @@
|
|
|
1
|
+
# phantasma-ts
|
|
2
|
+
|
|
3
|
+
A TypeScript SDK for the Phantasma blockchain.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Use the package manager [npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm) to install phatasma-ts.
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install phantasma-ts
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Importing
|
|
14
|
+
|
|
15
|
+
```javascript
|
|
16
|
+
const { PhantasmaTS } = require("phantasma-ts");
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Standalone HTML Import
|
|
20
|
+
|
|
21
|
+
```html
|
|
22
|
+
<script src="https://cdn.jsdelivr.net/gh/phantasma-io/phantasma-ts/html/phantasma.js"></script>
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
```javascript
|
|
26
|
+
phantasma.PhantasmaTS; // To use PhantasmaTS
|
|
27
|
+
phantasma.PhantasmaLink; // To use PhantasmaLink
|
|
28
|
+
phantasma.EasyConnect; // To use EasyConnect, an easy to use PhantasmaLink wrapper
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Table Of Contents
|
|
32
|
+
|
|
33
|
+
The Phantasma TypeScript SDK transpiles into PhantasmaTS, PhantasmaLink and EasyConnect.
|
|
34
|
+
|
|
35
|
+
1. [PhantasmaTS](#phantasmats) - Allows you to interact with the Phantasma Blockchain
|
|
36
|
+
|
|
37
|
+
- [Utility Functions](#phantasmats-utility-functions)
|
|
38
|
+
- [Script Builder](#building-a-script-with-script-builder)
|
|
39
|
+
- [Interop Commands](#interop-functions)
|
|
40
|
+
- [Building Transaction](#building-a-transaction)
|
|
41
|
+
- [Deploying Smart Contract](#deploying-a-contract)
|
|
42
|
+
- [RPC](#using-rpc)
|
|
43
|
+
|
|
44
|
+
2. [PhantasmaLink](#phantasmalink) - Allows you to interact with Phantasma based wallets
|
|
45
|
+
- [Functions](#functions)
|
|
46
|
+
- [Examples](#example-code)
|
|
47
|
+
|
|
48
|
+
3. [EasyConnect](#easyconnect) - Easy plug and play solution for creating DApps
|
|
49
|
+
|
|
50
|
+
- [Core Functions](#core-functions)
|
|
51
|
+
- [Query Function](#query-function)
|
|
52
|
+
- [Action Function](#action-function)
|
|
53
|
+
- [Easy Script](#easy-script-create)
|
|
54
|
+
|
|
55
|
+
4. [Misc]
|
|
56
|
+
- [Vocab](#vocab)
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## PhantasmaTS
|
|
61
|
+
|
|
62
|
+
Use PhantasmaTS to interact with the Phantasma blockchain directly.
|
|
63
|
+
|
|
64
|
+
### PhantasmaTS Utility Functions
|
|
65
|
+
|
|
66
|
+
Just some standard useful functions that you probably will end up using at some point.
|
|
67
|
+
|
|
68
|
+
```javascript
|
|
69
|
+
PhantasmaTS.byteArrayToHex(arr: ArrayBuffer | ArrayLike<number>); //Turns a Byte Array into Serialized Hex
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
```javascript
|
|
73
|
+
PhantasmaTS.getAddressFromWif(wif: string); //Get's Public Address from WIF (Wallet Import Format)
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
```javascript
|
|
77
|
+
PhantasmaTS.getPrivateKeyFromWif(wif: string); //Get's Private Key from WIF (Wallet Import Format)
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
```javascript
|
|
81
|
+
PhantasmaTS.hexToByteArray(hexBytes: string); //Turns Serialized Hex into Byte Array
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
```javascript
|
|
85
|
+
PhantasmaTS.reverseHex(hex: string); //Reverse <-> esreveR Serialized Hex
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
```javascript
|
|
89
|
+
PhantasmaTS.signData(msgHex: string, privateKey: string); //Signs some text with given Private Key
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Building a Script with Script Builder
|
|
93
|
+
|
|
94
|
+
Building a script is the most important part of interacting with the Phantasma blockchain. Without a propper script, the Phantasma blockchain will not know what you are trying to do.
|
|
95
|
+
|
|
96
|
+
These functions, `.CallContract` and `.CallInterop`, are your bread and butter for creating new scripts.
|
|
97
|
+
|
|
98
|
+
` .CallContract(contractName: string, methodName: string, [arguments]: array)`
|
|
99
|
+
|
|
100
|
+
` .CallInterop(functionName: string, [arguments]: array)`
|
|
101
|
+
|
|
102
|
+
- You can find out all the diffrent `.CallInterop` functions below.
|
|
103
|
+
|
|
104
|
+
- For `.CallContract`, you will have to look through the ABI's of all the diffrent smart contracts currently deployed on the Phantasma 'mainnet': [Link Here](https://explorer.phantasma.io/chain/main#tab_contracts)
|
|
105
|
+
|
|
106
|
+
#### Example:
|
|
107
|
+
|
|
108
|
+
```javascript
|
|
109
|
+
//Creating a new Script Builder Object
|
|
110
|
+
let sb = new PhantasmaTS.ScriptBuilder();
|
|
111
|
+
|
|
112
|
+
//Here is an example of a Transactional Script
|
|
113
|
+
sb
|
|
114
|
+
.AllowGas(fromAddress, sb.NullAddress, gasPrice, gasLimit)
|
|
115
|
+
.CallInterop("Runtime.TransferTokens", ['fromAddress', 'toAddress', 'KCAL', 10000000000]) //10000000000 = 1 KCAL
|
|
116
|
+
.SpendGas(fromAddress)
|
|
117
|
+
.EndScript();
|
|
118
|
+
|
|
119
|
+
--- OR ----
|
|
120
|
+
|
|
121
|
+
//Here is an example of a non Transactional Script
|
|
122
|
+
|
|
123
|
+
sb
|
|
124
|
+
.CallContract('account', 'LookUpName', ['accountName'])
|
|
125
|
+
.EndScript();
|
|
126
|
+
|
|
127
|
+
```
|
|
128
|
+
#### InvokeRawScript and decoding the result
|
|
129
|
+
```javascript
|
|
130
|
+
|
|
131
|
+
let sb = new PhantasmaTS.ScriptBuilder();
|
|
132
|
+
sb.CallContract("stake", "GetMasterCount", []);
|
|
133
|
+
let script = sb.EndScript();
|
|
134
|
+
let targetNet = 'main';
|
|
135
|
+
|
|
136
|
+
// NOTE - we assume RPC was instantiated previously already, check other samples to see how
|
|
137
|
+
let response = await RPC.invokeRawScript(targetNet, script);
|
|
138
|
+
|
|
139
|
+
const decoder = new PhantasmaTS.Decoder(response.result);
|
|
140
|
+
const value = decoder.readVmObject();
|
|
141
|
+
console.log(value); // print the decoded value to the console
|
|
142
|
+
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
#### Interop Functions:
|
|
146
|
+
|
|
147
|
+
Here are some Interop functions that are used to interact with the core functionality of the Phantasma blockchain. Use these inside your script to add extra functionality.
|
|
148
|
+
|
|
149
|
+
```javascript
|
|
150
|
+
sb.CallInterop("Runtime.MintTokens", [from: string, target: string, tokenSymbol: string , amount: number]); //Used for Fungible Tokens
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
```javascript
|
|
154
|
+
sb.CallInterop("Runtime.TransferTokens", [from: string, to: string, tokenSymbol: string, amount: number]); //Used for Fungible Tokens
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
```javascript
|
|
158
|
+
sb.CallInterop("Runtime.TransferBalance", [from: string, to: string, tokenSymbol: string]);
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
```javascript
|
|
162
|
+
sb.CallInterop("Runtime.TransferToken", [from: string, to: string, tokenSymbol: string, tokenId: number]); //Used for Non Fungible Tokens
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
```javascript
|
|
166
|
+
sb.CallInterop("Runtime.SendTokens", [destinationChain: string, from: string, to: string, tokenSymbol: string, amount: number); //Used for Fungible Tokens
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
```javascript
|
|
170
|
+
sb.CallInterop("Runtime.SendToken", [destinationChain: string, from: string, to: string, tokenSymbol: string, tokenId: number]); //Used for Non Fungible Tokens
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
```javascript
|
|
174
|
+
sb.CallInterop("Runtime.DeployContract", [from: string, contractName: string, pvm: hexString, abi: hexString]);
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### Building a Transaction
|
|
178
|
+
|
|
179
|
+
To build a transaction you will first need to build a script.
|
|
180
|
+
|
|
181
|
+
Note, building a Transaction is for transactional scripts only. Non transactional scripts should use the RPC function `RPC.invokeRawScript(chainInput: string, scriptData: string)`
|
|
182
|
+
|
|
183
|
+
```javascript
|
|
184
|
+
const { PhantasmaTS } = require("phantasma-ts");
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
async function sendTransaction() {
|
|
188
|
+
|
|
189
|
+
let WIF = "WIF"; //In WIF Format
|
|
190
|
+
let fromAddress = "yourPublicWalletAddress";
|
|
191
|
+
let toAddress = "addressYoureSendingTo";
|
|
192
|
+
|
|
193
|
+
//Creating RPC Connection **(Needs To Be Updated)
|
|
194
|
+
let RPC = new PhantasmaTS.PhantasmaAPI(
|
|
195
|
+
"http://localhost:7077/rpc",
|
|
196
|
+
null,
|
|
197
|
+
"simnet"
|
|
198
|
+
);
|
|
199
|
+
|
|
200
|
+
//set Gas parameters for Runtime.TransferTokens
|
|
201
|
+
let gasPrice = PhantasmaTS.DomainSettings.DefaultMinimumGasFee; //Internal Blockchain minimum gas fee needed - i.e 100000
|
|
202
|
+
let gasLimit = 9999;
|
|
203
|
+
|
|
204
|
+
//Creating a new Script Builder Object
|
|
205
|
+
let sb = new PhantasmaTS.ScriptBuilder();
|
|
206
|
+
|
|
207
|
+
//Making a Script
|
|
208
|
+
let script = sb
|
|
209
|
+
.BeginScript()
|
|
210
|
+
.AllowGas(fromAddress, sb.NullAddress, gasPrice, gasLimit)
|
|
211
|
+
.CallInterop("Runtime.TransferTokens", [
|
|
212
|
+
fromAddress,
|
|
213
|
+
toAddress,
|
|
214
|
+
"SOUL",
|
|
215
|
+
100000000,
|
|
216
|
+
]) //100000000 = 1 SOUL
|
|
217
|
+
.SpendGas(fromAddress)
|
|
218
|
+
.EndScript();
|
|
219
|
+
|
|
220
|
+
//Used to set expiration date
|
|
221
|
+
let expiration = 5; //This is in miniutes
|
|
222
|
+
let getTime = new Date();
|
|
223
|
+
let expiration_date = new Date(getTime.getTime() + expiration * 60000);
|
|
224
|
+
|
|
225
|
+
let payload = PhantasmaTS.Base16.encode("Phantasma-ts"); //Says '7068616e7461736d612d7473' in hex
|
|
226
|
+
|
|
227
|
+
//Creating New Transaction Object
|
|
228
|
+
let transaction = new PhantasmaTS.Transaction(
|
|
229
|
+
"simnet", //Nexus Name - if you're using mainnet change it to mainnet or simnet if you're using you localnode
|
|
230
|
+
"main", //Chain
|
|
231
|
+
script, //In string format
|
|
232
|
+
expiration_date, //Date Object
|
|
233
|
+
payload //Extra Info to attach to Transaction in Serialized Hex
|
|
234
|
+
);
|
|
235
|
+
|
|
236
|
+
//Sign's Transaction with WIF
|
|
237
|
+
transaction.sign(WIF);
|
|
238
|
+
let hexEncodedTx = transaction.ToStringEncoded(true); //converts trasnaction to base16 string -true means transaction is signed-
|
|
239
|
+
|
|
240
|
+
//Send Transaction
|
|
241
|
+
let txHash = await RPC.sendRawTransaction(hexEncodedTx);
|
|
242
|
+
//Return Transaction Hash
|
|
243
|
+
return txHash;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
```
|
|
247
|
+
### Staking SOUL
|
|
248
|
+
|
|
249
|
+
This is an example how to stake SOUL
|
|
250
|
+
|
|
251
|
+
```javascript
|
|
252
|
+
async function stakeSOUL() {
|
|
253
|
+
let WIF = "WIF"; //WIF format
|
|
254
|
+
|
|
255
|
+
let fromAddress = "yourPublicWalletAddress"; // Phantasma Public Address
|
|
256
|
+
|
|
257
|
+
//Creating a new Script Builder Object
|
|
258
|
+
let sb = new PhantasmaTS.ScriptBuilder();
|
|
259
|
+
let gasPrice = PhantasmaTS.DomainSettings.DefaultMinimumGasFee; //Internal Blockchain minimum gas fee needed - i.e 100000
|
|
260
|
+
let gasLimit = 21000;
|
|
261
|
+
let amount = String(10 * 10 ** 8); // 100 the amount - 10**8 it's to get the decimals to the desired amount
|
|
262
|
+
// Soul has 8 decimals places.
|
|
263
|
+
|
|
264
|
+
//Creating RPC Connection **(Needs To Be Updated)
|
|
265
|
+
let RPC = new PhantasmaTS.PhantasmaAPI(
|
|
266
|
+
"http://localhost:7077/rpc",
|
|
267
|
+
null,
|
|
268
|
+
"simnet"
|
|
269
|
+
);
|
|
270
|
+
|
|
271
|
+
//Making a Script
|
|
272
|
+
let script = sb
|
|
273
|
+
.AllowGas(fromAddress, sb.NullAddress, gasPrice, gasLimit)
|
|
274
|
+
.CallContract("stake", "Stake", [fromAddress, amount])
|
|
275
|
+
.SpendGas(fromAddress)
|
|
276
|
+
.EndScript();
|
|
277
|
+
|
|
278
|
+
//Used to set expiration date
|
|
279
|
+
let expiration = 5; //This is in miniutes
|
|
280
|
+
let getTime = new Date();
|
|
281
|
+
let expiration_date = new Date(getTime.getTime() + expiration * 60000);
|
|
282
|
+
|
|
283
|
+
let payload = "7068616e7461736d612d7473"; //Says 'Phantasma-ts' in hex
|
|
284
|
+
|
|
285
|
+
//Creating New Transaction Object
|
|
286
|
+
let transaction = new PhantasmaTS.Transaction(
|
|
287
|
+
"simnet", //Nexus Name - if you're using mainnet change it to mainnet
|
|
288
|
+
"main", //Chain
|
|
289
|
+
script, //In string format
|
|
290
|
+
expiration_date, //Date Object
|
|
291
|
+
payload //Extra Info to attach to Transaction in Serialized Hex
|
|
292
|
+
);
|
|
293
|
+
|
|
294
|
+
//Sign's Transaction with WIF
|
|
295
|
+
transaction.sign(WIF);
|
|
296
|
+
|
|
297
|
+
let hexEncodedTx = transaction.ToStringEncoded(true);
|
|
298
|
+
|
|
299
|
+
//Send Transaction
|
|
300
|
+
let txHash = await RPC.sendRawTransaction(hexEncodedTx);
|
|
301
|
+
|
|
302
|
+
//Return Transaction Hash
|
|
303
|
+
return txHash;
|
|
304
|
+
}
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
### Deploying a Contract
|
|
308
|
+
|
|
309
|
+
```javascript
|
|
310
|
+
async function deployContract() {
|
|
311
|
+
//Wallet Stuff
|
|
312
|
+
let WIF = "WIF"; //In wif Format
|
|
313
|
+
let fromAddress = "yourPublicWalletAddress";
|
|
314
|
+
|
|
315
|
+
//Contract Stuff
|
|
316
|
+
let pvm = "PVM HEX String";
|
|
317
|
+
let abi = "ABI HEX String";
|
|
318
|
+
|
|
319
|
+
//convert Pvm to Bytes -> uint8Array
|
|
320
|
+
let pvm_byteArr = PhantasmaTS.hexToByteArray(pvm);
|
|
321
|
+
pvm_byteArr.shift();
|
|
322
|
+
let byte_pvm = new Uint8Array(pvm_byteArr);
|
|
323
|
+
|
|
324
|
+
//convert abi to Bytes -> uint8Array
|
|
325
|
+
let abi_byteArr = PhantasmaTS.hexToByteArray(abi);
|
|
326
|
+
abi_byteArr.shift();
|
|
327
|
+
let byte_abi = new Uint8Array(abi_byteArr);
|
|
328
|
+
|
|
329
|
+
let gasPrice = PhantasmaTS.DomainSettings.DefaultMinimumGasFee; //Internal Blockchain minimum gas fee needed - i.e 100000
|
|
330
|
+
let gasLimit = 21000;
|
|
331
|
+
let contractName = "contractName"; //Whatever you want
|
|
332
|
+
|
|
333
|
+
//Creating a new Script Builder Object
|
|
334
|
+
let sb = new PhantasmaTS.ScriptBuilder();
|
|
335
|
+
|
|
336
|
+
//New RPC and Peers Needed
|
|
337
|
+
//Creating RPC Connection, use ('http://testnet.phantasma.io:5101/rpc', null, 'testnet') for testing
|
|
338
|
+
let RPC = new PhantasmaTS.PhantasmaAPI(
|
|
339
|
+
"http://localhost:7077/rpc",
|
|
340
|
+
null,
|
|
341
|
+
"simnet"
|
|
342
|
+
);
|
|
343
|
+
|
|
344
|
+
//Making a Script
|
|
345
|
+
let script = sb
|
|
346
|
+
.AllowGas(fromAddress, sb.NullAddress, gasPrice, gasLimit)
|
|
347
|
+
.CallInterop("Runtime.DeployContract", [
|
|
348
|
+
fromAddress,
|
|
349
|
+
contractName,
|
|
350
|
+
byte_pvm,
|
|
351
|
+
byte_abi,
|
|
352
|
+
])
|
|
353
|
+
.SpendGas(fromAddress)
|
|
354
|
+
.EndScript();
|
|
355
|
+
|
|
356
|
+
//Used to set expiration date
|
|
357
|
+
let expiration = 5; //This is in miniutes
|
|
358
|
+
let getTime = new Date();
|
|
359
|
+
let expiration_date = new Date(getTime.getTime() + expiration * 60000);
|
|
360
|
+
|
|
361
|
+
//Setting Temp Payload
|
|
362
|
+
let payload = "MyApp";
|
|
363
|
+
|
|
364
|
+
//Creating New Transaction Object
|
|
365
|
+
let transaction = new PhantasmaTS.Transaction(
|
|
366
|
+
"simnet", //Nexus Name
|
|
367
|
+
"main", //Chain
|
|
368
|
+
script, //In string format
|
|
369
|
+
expiration_date, //Date Object
|
|
370
|
+
payload //Extra Info to attach to Transaction in Serialized Hex
|
|
371
|
+
);
|
|
372
|
+
|
|
373
|
+
//Deploying Contract Requires POW -- Use a value of 5 to increase the hash difficulty by at least 5
|
|
374
|
+
transaction.mineTransaction(5);
|
|
375
|
+
|
|
376
|
+
//Signs Transaction with your WIF
|
|
377
|
+
transaction.sign(WIF);
|
|
378
|
+
|
|
379
|
+
let hexEncodedTx = transaction.ToStringEncoded(true);
|
|
380
|
+
|
|
381
|
+
//Sends Transaction
|
|
382
|
+
let txHash = await RPC.sendRawTransaction(hexEncodedTx);
|
|
383
|
+
|
|
384
|
+
//Returns Transaction Hash
|
|
385
|
+
return txHash;
|
|
386
|
+
}
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
### Scanning the blockchain for incoming transactions
|
|
390
|
+
|
|
391
|
+
```javascript
|
|
392
|
+
const { PhantasmaTS } = require("phantasma-ts");
|
|
393
|
+
|
|
394
|
+
let RPC = new PhantasmaTS.PhantasmaAPI(
|
|
395
|
+
"http://pharpc1.phantasma.io:7077/rpc",
|
|
396
|
+
null,
|
|
397
|
+
"mainnet"
|
|
398
|
+
);
|
|
399
|
+
|
|
400
|
+
// Store the current height of the chain
|
|
401
|
+
let currentHeight = 1;
|
|
402
|
+
|
|
403
|
+
let chainName = "main";
|
|
404
|
+
|
|
405
|
+
function onTransactionReceived(address, symbol, amount) {}
|
|
406
|
+
|
|
407
|
+
// Function that periodically checks the height of the chain and fetches the latest block if the height has increased
|
|
408
|
+
async function checkForNewBlocks() {
|
|
409
|
+
// Get the current height of the chain
|
|
410
|
+
let newHeight = await RPC.getBlockHeight(chainName);
|
|
411
|
+
|
|
412
|
+
// Check if the height has increased
|
|
413
|
+
if (newHeight > currentHeight) {
|
|
414
|
+
// Fetch the latest block
|
|
415
|
+
let latestBlock = await RPC.getBlockByHeight(chainName, newHeight);
|
|
416
|
+
|
|
417
|
+
// Check all transactions in this block
|
|
418
|
+
for (i = 0; i < latestBlock.txs.length; i++) {
|
|
419
|
+
let tx = latestBlock.txs[i];
|
|
420
|
+
|
|
421
|
+
// Check all events in this transaction
|
|
422
|
+
for (j = 0; j < tx.events.length; j++) {
|
|
423
|
+
let evt = tx.events[j];
|
|
424
|
+
if (evt.kind == "TokenReceive") {
|
|
425
|
+
var data = PhantasmaTS.getTokenEventData(evt.data);
|
|
426
|
+
onTransactionReceived(evt.address, data.symbol, data.value);
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
// Update the current height of the chain
|
|
432
|
+
currentHeight = newHeight;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
// Repeat this process after a delay
|
|
436
|
+
setTimeout(checkForNewBlocks, 1000);
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
// Start checking for new blocks
|
|
440
|
+
checkForNewBlocks();
|
|
441
|
+
```
|
|
442
|
+
|
|
443
|
+
### Using RPC
|
|
444
|
+
|
|
445
|
+
```javascript
|
|
446
|
+
let RPC = new PhantasmaTS.PhantasmaAPI(
|
|
447
|
+
"http://pharpc1.phantasma.io:7077/rpc",
|
|
448
|
+
null,
|
|
449
|
+
"mainnet"
|
|
450
|
+
);
|
|
451
|
+
```
|
|
452
|
+
|
|
453
|
+
#### Utillities:
|
|
454
|
+
|
|
455
|
+
- `RPC.JSONRPC(method: string, params: Array<any>);` <- Used to make any Phantasma RPC call
|
|
456
|
+
- ` RPC.updateRpc()`
|
|
457
|
+
- ` RPC.setRpcHost(rpcHost: string)`
|
|
458
|
+
- ` RPC.setRpcByName(rpcName: string)`
|
|
459
|
+
- ` RPC.setNexus(nexus: string)`
|
|
460
|
+
- ` RPC.convertDecimals(amount: number, decimals: number)`
|
|
461
|
+
|
|
462
|
+
#### All RPC Function Calls:
|
|
463
|
+
|
|
464
|
+
```javascript
|
|
465
|
+
await RPC.getAccount(account: string); //Returns the account name and balance of given address.
|
|
466
|
+
```
|
|
467
|
+
|
|
468
|
+
```javascript
|
|
469
|
+
await RPC.lookUpName(name: string); //Returns the address that owns a given name.
|
|
470
|
+
```
|
|
471
|
+
|
|
472
|
+
```javascript
|
|
473
|
+
await RPC.getBlockHeight(chainInput: string); //Returns the height of a chain.
|
|
474
|
+
```
|
|
475
|
+
|
|
476
|
+
```javascript
|
|
477
|
+
await RPC.getBlockTransactionCountByHash(blockHash: string); //Returns the number of transactions of given block hash or error if given hash is invalid or is not found.
|
|
478
|
+
```
|
|
479
|
+
|
|
480
|
+
```javascript
|
|
481
|
+
await RPC.getBlockByHash(blockHash: string); //Returns information about a block by hash.
|
|
482
|
+
```
|
|
483
|
+
|
|
484
|
+
```javascript
|
|
485
|
+
await RPC.getRawBlockByHash(blockHash: string); //Returns a serialized string, containing information about a block by hash.
|
|
486
|
+
```
|
|
487
|
+
|
|
488
|
+
```javascript
|
|
489
|
+
await RPC.getBlockByHeight(chainInput: string, height: number); //Returns information about a block by height and chain.
|
|
490
|
+
```
|
|
491
|
+
|
|
492
|
+
```javascript
|
|
493
|
+
await RPC.getRawBlockByHeight(chainInput: string, height: number); //Returns a serialized string, in hex format, containing information about a block by height and chain.
|
|
494
|
+
```
|
|
495
|
+
|
|
496
|
+
```javascript
|
|
497
|
+
await RPC.getTransactionByBlockHashAndIndex(blockHash: string, index: number); //Returns the information about a transaction requested by a block hash and transaction index.
|
|
498
|
+
```
|
|
499
|
+
|
|
500
|
+
```javascript
|
|
501
|
+
await RPC.getAddressTransactions(account: string, page: number, pageSize: number); //Returns last X transactions of given address.
|
|
502
|
+
```
|
|
503
|
+
|
|
504
|
+
```javascript
|
|
505
|
+
await RPC.getAddressTransactionCount(account: string, chainInput: string); //Get number of transactions in a specific address and chain.
|
|
506
|
+
```
|
|
507
|
+
|
|
508
|
+
```javascript
|
|
509
|
+
await RPC.sendRawTransaction(txData: string); //Allows to broadcast a signed operation on the network, but it's required to build it manually.
|
|
510
|
+
```
|
|
511
|
+
|
|
512
|
+
```javascript
|
|
513
|
+
await RPC.invokeRawScript(chainInput: string, scriptData: string); //Allows to invoke script based on network state, without state changes.
|
|
514
|
+
```
|
|
515
|
+
|
|
516
|
+
```javascript
|
|
517
|
+
await RPC.getTransaction(hashText: string); //Returns information about a transaction by hash.
|
|
518
|
+
```
|
|
519
|
+
|
|
520
|
+
```javascript
|
|
521
|
+
await RPC.cancelTransaction(hashText: string); //Removes a pending transaction from the mempool.
|
|
522
|
+
```
|
|
523
|
+
|
|
524
|
+
```javascript
|
|
525
|
+
await RPC.getChains(); //Returns an array of all chains deployed in Phantasma.
|
|
526
|
+
```
|
|
527
|
+
|
|
528
|
+
```javascript
|
|
529
|
+
await RPC.getNexus(); //Returns info about the nexus.
|
|
530
|
+
```
|
|
531
|
+
|
|
532
|
+
```javascript
|
|
533
|
+
await RPC.getOrganization(ID: string); //Returns info about an organization.
|
|
534
|
+
```
|
|
535
|
+
|
|
536
|
+
```javascript
|
|
537
|
+
await RPC.getLeaderboard(name: string); //Returns content of a Phantasma leaderboard.
|
|
538
|
+
```
|
|
539
|
+
|
|
540
|
+
```javascript
|
|
541
|
+
await RPC.getTokens(); //Returns an array of tokens deployed in Phantasma.
|
|
542
|
+
```
|
|
543
|
+
|
|
544
|
+
```javascript
|
|
545
|
+
await RPC.getToken(symbol: string); //Returns info about a specific token deployed in Phantasma.
|
|
546
|
+
```
|
|
547
|
+
|
|
548
|
+
```javascript
|
|
549
|
+
await RPC.getTokenData(symbol: string, IDtext: string); //Returns data of a non-fungible token, in hexadecimal format.
|
|
550
|
+
```
|
|
551
|
+
|
|
552
|
+
```javascript
|
|
553
|
+
await RPC.getTokenBalance(account: string, tokenSymbol: string, chainInput: string); //Returns the balance for a specific token and chain, given an address.
|
|
554
|
+
```
|
|
555
|
+
|
|
556
|
+
```javascript
|
|
557
|
+
await RPC.getAuctionsCount(chainAddressOrName: string, symbol: string); //Returns the number of active auctions.
|
|
558
|
+
```
|
|
559
|
+
|
|
560
|
+
```javascript
|
|
561
|
+
await RPC.getAuctions(chainAddressOrName: string, symbol: string, page: number, pageSize: number); //Returns the auctions available in the market.
|
|
562
|
+
```
|
|
563
|
+
|
|
564
|
+
```javascript
|
|
565
|
+
await RPC.getAuction(chainAddressOrName: string, symbol: string, IDtext: string); //Returns the auction for a specific token.
|
|
566
|
+
```
|
|
567
|
+
|
|
568
|
+
```javascript
|
|
569
|
+
await RPC.getArchive(hashText: string)getArchive(hashText: string); //Returns info about a specific archive.
|
|
570
|
+
```
|
|
571
|
+
|
|
572
|
+
```javascript
|
|
573
|
+
await RPC.writeArchive(hashText: string, blockIndex: number, blockContent: string); //Writes the contents of an incomplete archive.
|
|
574
|
+
```
|
|
575
|
+
|
|
576
|
+
```javascript
|
|
577
|
+
await RPC.getABI(chainAddressOrName: string, contractName: string); //Returns the ABI interface of specific contract.
|
|
578
|
+
```
|
|
579
|
+
|
|
580
|
+
```javascript
|
|
581
|
+
await RPC.getPeers(); //Returns list of known peers.
|
|
582
|
+
```
|
|
583
|
+
|
|
584
|
+
```javascript
|
|
585
|
+
await RPC.relaySend(receiptHex: string); //Writes a message to the relay network.
|
|
586
|
+
```
|
|
587
|
+
|
|
588
|
+
```javascript
|
|
589
|
+
await RPC.relayReceive(account: string); //Receives messages from the relay network.
|
|
590
|
+
```
|
|
591
|
+
|
|
592
|
+
```javascript
|
|
593
|
+
await RPC.getEvents(account: string); //Reads pending messages from the relay network.
|
|
594
|
+
```
|
|
595
|
+
|
|
596
|
+
```javascript
|
|
597
|
+
await RPC.getPlatforms(); //Returns an array of available interop platforms.
|
|
598
|
+
```
|
|
599
|
+
|
|
600
|
+
```javascript
|
|
601
|
+
await RPC.getValidators(); //Returns an array of available validators.
|
|
602
|
+
```
|
|
603
|
+
|
|
604
|
+
```javascript
|
|
605
|
+
await RPC.settleSwap(sourcePlatform: string, destPlatform: string, hashText: string); //Tries to settle a pending swap for a specific hash.
|
|
606
|
+
```
|
|
607
|
+
|
|
608
|
+
```javascript
|
|
609
|
+
await RPC.getSwapsForAddressOld(account: string); //Returns platform swaps for a specific address.
|
|
610
|
+
```
|
|
611
|
+
|
|
612
|
+
```javascript
|
|
613
|
+
await RPC.getSwapsForAddress(account: string, platform: string); //Returns platform swaps for a specific address.
|
|
614
|
+
```
|
|
615
|
+
|
|
616
|
+
```javascript
|
|
617
|
+
await RPC.getNFT(symbol: string, nftId: string); //Returns info of a nft.
|
|
618
|
+
```
|
|
619
|
+
|
|
620
|
+
## PhantasmaLink
|
|
621
|
+
|
|
622
|
+
PhantasmaLink is a core connecting piece that allows you to interact with Phantasma based Wallets. PhantasmaLink is a building block to help you connect with wallets, however if you are more interested in using a more simple plug and play product, please see [EasyConnect](#easyconnect) **<- Super Useful**
|
|
623
|
+
|
|
624
|
+
Since phantasmaLink is a Class we are going to initiate a new phantasmaLink object.
|
|
625
|
+
|
|
626
|
+
```javascript
|
|
627
|
+
let dappID = "Dapp Name"; //This is just the name you want to give the connection
|
|
628
|
+
let consoleLogging = true; //This is if you want console logging for Debugging Purposes [Default is set to true]
|
|
629
|
+
|
|
630
|
+
let link = new PhantasmaLink(dappID, consoleLogging);
|
|
631
|
+
```
|
|
632
|
+
|
|
633
|
+
#### Vocab
|
|
634
|
+
|
|
635
|
+
- ` Callback - Function that gets called on after a success`
|
|
636
|
+
- ` onErrorCallback - Function that gets called on after a failure`
|
|
637
|
+
- ` Script - A set of instructions for that PhantasmaChain to decode that lies inside of a transaction object` See [ScriptBuilder](#building-a-script-with-script-builder)
|
|
638
|
+
- ` Nexus - The chain on Phantasma that is being used: Either 'mainnet' or 'testnet'`
|
|
639
|
+
- ` Payload - Extra data attached to a transaction object`
|
|
640
|
+
- ` ProviderHint - Tells PhantasmaLink which wallet you intend to connect with`
|
|
641
|
+
|
|
642
|
+
### Functions:
|
|
643
|
+
|
|
644
|
+
```javascript
|
|
645
|
+
link.login(onLoginCallback, onErrorCallback, providerHint); //Provider Hint can be 'ecto' or 'poltergeist'
|
|
646
|
+
```
|
|
647
|
+
|
|
648
|
+
```javascript
|
|
649
|
+
link.invokeScript(script, callback); //Allows you to do a ReadOnly script operation on the Phantasma Blockchain (Sends results as an Argument to Callback Function)
|
|
650
|
+
```
|
|
651
|
+
|
|
652
|
+
```javascript
|
|
653
|
+
link.signTx(nexus, script, payload, callback, onErrorCallback); //Signs a Transaction via Wallet (payload can be Null) (Sends results as an Argument to Callback Function)
|
|
654
|
+
```
|
|
655
|
+
|
|
656
|
+
```javascript
|
|
657
|
+
link.signTxPow(nexus, script, payload, proofOfWork, callback, onErrorCallback); //Signs a Transaction via Wallet with ProofOfWork Attached (Used for Contract Deployment)
|
|
658
|
+
|
|
659
|
+
//ProofOfWork Enum
|
|
660
|
+
enum ProofOfWork {
|
|
661
|
+
None = 0,
|
|
662
|
+
Minimal = 5,
|
|
663
|
+
Moderate = 15,
|
|
664
|
+
Hard = 19,
|
|
665
|
+
Heavy = 24,
|
|
666
|
+
Extreme = 30
|
|
667
|
+
}
|
|
668
|
+
```
|
|
669
|
+
|
|
670
|
+
```javascript
|
|
671
|
+
link.getPeer(callback, onErrorCallback); //Get's the peer list for the currently connected network
|
|
672
|
+
```
|
|
673
|
+
|
|
674
|
+
```javascript
|
|
675
|
+
link.signData(data, callback, onErrorCallback); //Allows you to sign some data via your Wallet (Sends results as an Argument to Callback Function)
|
|
676
|
+
```
|
|
677
|
+
|
|
678
|
+
```javascript
|
|
679
|
+
link.toggleMessageLogging(); //Toggles Console Message Logging
|
|
680
|
+
```
|
|
681
|
+
|
|
682
|
+
```javascript
|
|
683
|
+
link.dappID(); //Returns DappID
|
|
684
|
+
```
|
|
685
|
+
|
|
686
|
+
```javascript
|
|
687
|
+
link.sendLinkRequest(request, callback); //Used internally and sends wallet instructions through socket, you probably won't use it unless you know what your doing
|
|
688
|
+
```
|
|
689
|
+
|
|
690
|
+
```javascript
|
|
691
|
+
link.createSocket(); //Used internally to connect to wallet, you probably won't use it unless you know what your doing
|
|
692
|
+
link.retry(); //Used internally to retry socket connection, you probably won't use it unless you know what your doing
|
|
693
|
+
```
|
|
694
|
+
|
|
695
|
+
```javascript
|
|
696
|
+
link.disconnect(message); //Disconnects From Socket (You can add a reason with the Message Argument)
|
|
697
|
+
```
|
|
698
|
+
|
|
699
|
+
|
|
700
|
+
### Example Code
|
|
701
|
+
Here is some example code to initate a wallet connection.
|
|
702
|
+
|
|
703
|
+
```javascript
|
|
704
|
+
let link = new PhantasmaLink("Dapp"); //"Dapp" is just whatever name you want to give your application
|
|
705
|
+
|
|
706
|
+
//Use this code snippet to connect to a phantasma wallet
|
|
707
|
+
link.login(
|
|
708
|
+
function (success) {
|
|
709
|
+
//Console Logging for Debugging Purposes
|
|
710
|
+
if (success) {
|
|
711
|
+
console.log(
|
|
712
|
+
"Connected to account " + this.account.address + " via " + this.wallet
|
|
713
|
+
);
|
|
714
|
+
} else {
|
|
715
|
+
console.log("Connection Failed");
|
|
716
|
+
}
|
|
717
|
+
},
|
|
718
|
+
(data) => {
|
|
719
|
+
console.log(data);
|
|
720
|
+
},
|
|
721
|
+
"ecto"
|
|
722
|
+
); //Swap out ecto for 'poltergeist' if wanting to connect to Poltergeist Wallet
|
|
723
|
+
```
|
|
724
|
+
|
|
725
|
+
## EasyConnect
|
|
726
|
+
|
|
727
|
+
EasyConnect is a plug and play wrapper for PhantasmaLink that makes creating a DApp simple and easy.
|
|
728
|
+
|
|
729
|
+
Since EasyConnect is a Class we are going to initiate a new EasyConnect object.
|
|
730
|
+
|
|
731
|
+
```javascript
|
|
732
|
+
//Optional Arguments [ requiredVersion: number, platform: string, providerHint: string]
|
|
733
|
+
let link = new EasyConnect(); //Has Optional Arguments input as Array
|
|
734
|
+
```
|
|
735
|
+
|
|
736
|
+
### Core Functions
|
|
737
|
+
|
|
738
|
+
```javascript
|
|
739
|
+
link.connect(onSuccess, onFail); //Has two optional callback functions, one for Success and one for Failure
|
|
740
|
+
```
|
|
741
|
+
|
|
742
|
+
```javascript
|
|
743
|
+
link.disconnect(_message: string); //Allows you to disconnect from the wallet with a desired message
|
|
744
|
+
```
|
|
745
|
+
|
|
746
|
+
```javascript
|
|
747
|
+
link.signTransaction(script: string, payload: string, onSuccess, onFail); //Used to send a transaction to Wallet
|
|
748
|
+
```
|
|
749
|
+
|
|
750
|
+
```javascript
|
|
751
|
+
link.signData(data:any, onSuccess, onFail); //Allows you to sign data with a wallet keypair
|
|
752
|
+
```
|
|
753
|
+
|
|
754
|
+
```javascript
|
|
755
|
+
link.setConfig(_provider: string); //Allows you to set wallet provider, 'auto', 'ecto', 'poltergeist' (Default is already set to 'auto')
|
|
756
|
+
```
|
|
757
|
+
|
|
758
|
+
```javascript
|
|
759
|
+
//Allows Async aswell
|
|
760
|
+
link.query(_type: string, _arguments: Array<string>, _callback); //Allows you to query connected wallet/account information (arguments and callback are optional)
|
|
761
|
+
```
|
|
762
|
+
|
|
763
|
+
```javascript
|
|
764
|
+
//Allows Async aswell
|
|
765
|
+
link.action(_type: string, _arguments: Array<string>, _callback); //Allows you to send a specified action quickly
|
|
766
|
+
```
|
|
767
|
+
|
|
768
|
+
```javascript
|
|
769
|
+
//Allows Async aswell
|
|
770
|
+
link.script.buildScript(_type: string, _arguments: Array<string>, _callback); //Allows you to quickly create a script with only arguments
|
|
771
|
+
// Script Types
|
|
772
|
+
// 'interact', [contractName, methodName, [arguments]]
|
|
773
|
+
// 'invoke', [contractName, methodName, [arguments]]
|
|
774
|
+
// 'interop', [interopName, [arguments]]
|
|
775
|
+
```
|
|
776
|
+
|
|
777
|
+
```javascript
|
|
778
|
+
link.invokeScript(script: string, _callback); //Allows you to query data from smart contracts on Phantasma (Non Transactional)
|
|
779
|
+
```
|
|
780
|
+
|
|
781
|
+
```javascript
|
|
782
|
+
link.deployContract(script: string, payload:string, proofOfWork, onSuccess, onFail) //Allows you to deploy a contract script
|
|
783
|
+
|
|
784
|
+
//Proof of Work Enum
|
|
785
|
+
export enum ProofOfWork {
|
|
786
|
+
None = 0,
|
|
787
|
+
Minimal = 5,
|
|
788
|
+
Moderate = 15,
|
|
789
|
+
Hard = 19,
|
|
790
|
+
Heavy = 24,
|
|
791
|
+
Extreme = 30
|
|
792
|
+
}
|
|
793
|
+
```
|
|
794
|
+
|
|
795
|
+
### Query Function
|
|
796
|
+
|
|
797
|
+
The Query function is an async function that also allows you to use callbacks. You can use it is a promise, or in a chain!
|
|
798
|
+
|
|
799
|
+
```javascript
|
|
800
|
+
await link.query("account"); //Retrieves all connected wallet account information
|
|
801
|
+
```
|
|
802
|
+
|
|
803
|
+
```javascript
|
|
804
|
+
await link.query("name"); //Retrieves registered name associated with connect wallet
|
|
805
|
+
```
|
|
806
|
+
|
|
807
|
+
```javascript
|
|
808
|
+
await link.query("balances"); //Shows complete token balance accociated with connected wallet
|
|
809
|
+
```
|
|
810
|
+
|
|
811
|
+
```javascript
|
|
812
|
+
await link.query("walletAddress"); //Shows connected wallet address
|
|
813
|
+
```
|
|
814
|
+
|
|
815
|
+
```javascript
|
|
816
|
+
await link.query("avatar"); //Shows connected wallet avatar
|
|
817
|
+
```
|
|
818
|
+
|
|
819
|
+
### Action Function
|
|
820
|
+
|
|
821
|
+
The Action function is an async function that also allows you to use callbacks. You can use it is a promise, or in a chain!
|
|
822
|
+
|
|
823
|
+
```javascript
|
|
824
|
+
await link.action('sendFT', [fromAddress:string, toAddress:string, tokenSymbol:string, amount:number]); //Send Fungible Token
|
|
825
|
+
```
|
|
826
|
+
|
|
827
|
+
```javascript
|
|
828
|
+
await link.action('sendNFT', [fromAddress:string, toAddress:string, tokenSymbol:string, tokenID:number]); //Send Non Fungible Token
|
|
829
|
+
```
|
|
830
|
+
|
|
831
|
+
### Easy Script Create
|
|
832
|
+
|
|
833
|
+
(WIP)
|
|
834
|
+
Allows you to generate scripts quickly.
|
|
835
|
+
|
|
836
|
+
```javascript
|
|
837
|
+
async buildScript(_type: string, _options: Array<any>);
|
|
838
|
+
// Script Types
|
|
839
|
+
// 'interact', [contractName, methodName, [arguments]]
|
|
840
|
+
// 'invoke', [contractName, methodName, [arguments]]
|
|
841
|
+
// 'interop', [interopName, [arguments]]
|
|
842
|
+
```
|