Gathering detailed insights and metrics for @terra-money/terra.js
Gathering detailed insights and metrics for @terra-money/terra.js
Gathering detailed insights and metrics for @terra-money/terra.js
Gathering detailed insights and metrics for @terra-money/terra.js
@terra-money/wallet-types
This is a separate package because it is used for [`@terra-money/use-wallet`](https://www.npmjs.com/package/@terra-money/use-wallet), [`@terra-money/wallet-controller`](https://www.npmjs.com/package/@terra-money/wallet-controller), and [`@terra-money/wall
@terra-money/feather.js
TypeScript SDK for Terra and Cosmos chains
@anchor-protocol/anchor.js
Anchor.js is a client SDK for building applications that can interact with Anchor Protocol from within JavaScript runtimes, such as web browsers, server backends, and on mobile through React Native.
@terra-money/wallet-provider
Library to make React dApps easier using Terra Station Extension or Terra Station Mobile.
npm install @terra-money/terra.js
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
262 Stars
550 Commits
153 Forks
33 Watching
18 Branches
38 Contributors
Updated on 09 Oct 2024
TypeScript (99.74%)
JavaScript (0.26%)
Cumulative downloads
Total Downloads
Last day
16.1%
3,597
Compared to previous day
Last week
3.1%
19,902
Compared to previous week
Last month
2.6%
77,962
Compared to previous month
Last year
4.6%
943,916
Compared to previous year
14
25
The JavaScript SDK for Terra
Explore the Docs »
Examples
·
API Reference
·
NPM Package
·
GitHub
Terra.js is a JavaScript SDK for writing applications that interact with the Terra blockchain from either Node.js, browser, or React Native environments and provides simple abstractions over core data structures, serialization, key management, and API request generation.
LCDClient
We highly suggest using Terra.js with TypeScript, or JavaScript in a code editor that has support for type declarations, so you can take advantage of the helpful type hints that are included with the package.
Grab the latest version off NPM:
1npm install @terra-money/terra.js
Terra.js can be used in Node.js, as well as inside the browser. Please check the docs for notes on how to get up and running.
:exclamation: terra.js can connect both terra-classic and terra network. If you want to communicate with classic chain, you have to set isClassic as true
.
1import { LCDClient, Coin } from '@terra-money/terra.js';
2
3// connect to pisco testnet
4const terra = new LCDClient({
5 URL: 'https://pisco-lcd.terra.dev',
6 chainID: 'pisco-1',
7 isClassic: false // if it is unset, LCDClient assumes the flag is false.
8});
9
10// connect to columbus-5 terra classic network
11const terra = new LCDClient({
12 URL: 'https://columbus-lcd.terra.dev',
13 chainID: 'columbus-5',
14 isClassic: true // *set to true to connect terra-classic chain*
15});
16
17// To use LocalTerra
18// const terra = new LCDClient({
19// URL: 'http://localhost:1317',
20// chainID: 'localterra'
21// });
22
23// get the current balance of `terra1x46rqay4d3cssq8gxxvqz8xt6nwlz4td20k38v`
24const balance = terra.bank.balance('terra1x46rqay4d3cssq8gxxvqz8xt6nwlz4td20k38v');
25console.log(balance);
First, get some testnet tokens for terra1x46rqay4d3cssq8gxxvqz8xt6nwlz4td20k38v
, or use LocalTerra.
1import { LCDClient, MsgSend, MnemonicKey } from '@terra-money/terra.js';
2
3// create a key out of a mnemonic
4const mk = new MnemonicKey({
5 mnemonic:
6 'notice oak worry limit wrap speak medal online prefer cluster roof addict wrist behave treat actual wasp year salad speed social layer crew genius',
7});
8
9// connect to bombay testnet
10const terra = new LCDClient({
11 URL: 'https://pisco-lcd.terra.dev',
12 chainID: 'pisco-1',
13});
14
15// To use LocalTerra
16// const terra = new LCDClient({
17// URL: 'http://localhost:1317',
18// chainID: 'localterra'
19// });
20
21// a wallet can be created out of any key
22// wallets abstract transaction building
23const wallet = terra.wallet(mk);
24
25// create a simple message that moves coin balances
26const send = new MsgSend(
27 'terra1x46rqay4d3cssq8gxxvqz8xt6nwlz4td20k38v',
28 'terra17lmam6zguazs5q5u6z5mmx76uj63gldnse2pdp',
29 { uluna: 1200000}
30);
31
32wallet
33 .createAndSignTx({
34 msgs: [send],
35 memo: 'test from terra.js!',
36 })
37 .then(tx => terra.tx.broadcast(tx))
38 .then(result => {
39 console.log(`TX hash: ${result.txhash}`);
40 });
You can access all the objects of the @terra-money/terra.js
from the global Terra
object if you load Terra.js with a <script>
tag.
Include the following in your browser:
1<script 2 crossorigin 3 src="https://unpkg.com/@terra-money/terra.js/dist/bundle.js" 4></script>
You can find a small JSFiddle example that refreshes current Oracle votes here.
In order to use Terra.js inside React Native, you need to add the node-libs-react-native
package and react-native-get-random-values
package to your React Native app's package.json
.
1yarn add node-libs-react-native react-native-get-random-values
You will need to register Node.js native modules in an entry point of your application, such as index.tsx
:
1import 'node-libs-react-native/globals'; 2import 'react-native-get-random-values';
Also, add resolvers to your metro.config.js
1module.exports { 2 // ... 3 resolver: { 4 // ... 5 extraNodeModules: require('node-libs-react-native'), 6 }, 7 // ... 8}
This software is licensed under the MIT license. See LICENSE for full disclosure.
© 2020 Terraform Labs, PTE.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
Found 12/15 approved changesets -- score normalized to 8
Reason
binaries present in source code
Details
Reason
dependency not pinned by hash detected -- score normalized to 3
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
19 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More