-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Thorchain transfer example * tsconfig
- Loading branch information
Showing
8 changed files
with
105 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
// These tasks will run in order when initializing your CodeSandbox project. | ||
"setupTasks": [ | ||
{ | ||
"name": "Install Dependencies", | ||
"command": "yarn install" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"name": "Devcontainer", | ||
"image": "ghcr.io/codesandbox/devcontainers/typescript-node:latest" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# xchainjs-thorchain | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Thorchain | ||
|
||
Thorchain examples to show different use cases using its client | ||
|
||
## Examples | ||
|
||
### Transactions | ||
|
||
#### Make transaction | ||
|
||
Check out how you should make a Thorchain native asset transaction in this [example](https://github.com/xchainjs/xchainjs-lib/blob/master/examples/thorchain/transaction-transfer.ts) or run it as | ||
|
||
```sh | ||
yarn transfer phrase recipient amount | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"name": "xchainjs-thorchain", | ||
"private": true, | ||
"version": "0.0.1", | ||
"scripts": { | ||
"transfer": "npx ts-node transaction-transfer.ts", | ||
"build": "tsc --noEmit" | ||
}, | ||
"description": "Examples using Thorchain client", | ||
"main": "index.js", | ||
"license": "MIT", | ||
"dependencies": { | ||
"@xchainjs/xchain-thorchain": "workspace:*", | ||
"@xchainjs/xchain-util": "workspace:*" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "20.11.28", | ||
"ts-node": "10.9.2", | ||
"typescript": "^5.0.4" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { Client, defaultClientConfig } from '@xchainjs/xchain-thorchain' | ||
import { assetAmount, assetToBase } from '@xchainjs/xchain-util' | ||
|
||
const main = async () => { | ||
const phrase = `${process.argv[2]}` | ||
const recipient = `${process.argv[3]}` | ||
const amount = assetAmount(`${process.argv[4]}`, 8) | ||
|
||
const client = new Client({ | ||
...defaultClientConfig, | ||
phrase, | ||
}) | ||
|
||
const hash = await client.transfer({ | ||
recipient, | ||
amount: assetToBase(amount), | ||
}) | ||
|
||
console.log({ | ||
hash, | ||
url: client.getExplorerTxUrl(hash), | ||
}) | ||
} | ||
|
||
main() | ||
.then(() => process.exit(0)) | ||
.catch((err) => console.error(err)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"target": "es5", | ||
"noEmitOnError": true, | ||
"resolveJsonModule": true, | ||
"esModuleInterop": true, | ||
"lib": [ | ||
"es6", | ||
"dom", | ||
"es2016", | ||
"es2017" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters