Terra


Examples


Querying Anchor borrow limit

    ctx := context.Background()
	
    querier := terra.NewQuerier(
		httpClient := &http.Client{
            Timeout: 30 * time.Second,
		}, 
		"https://lcd.terra.dev")
	
    walletAddress, err := cosmos.AccAddressFromBech32("walletAddress")

    anc, err := anchor.NewAnchor(querier)
    if err != nil {
        panic(err)
    }
    borrowLimit, err := anc.Overseer.BorrowLimit(ctx, walletAddress)
    if err != nil {
        panic(err)
    }
	

Depositing UST to Anchor

    ctx := context.Background()
	
    querier := terra.NewQuerier(
		httpClient := &http.Client{
            Timeout: 30 * time.Second,
		}, 
		"https://lcd.terra.dev")
	
    wallet, err := terra.NewWalletFromMnemonic(
        querier,
        "mnemonic",
        0,
        0)
    if err != nil {
        panic(err)
    }

    anc, err := anchor.NewAnchor(querier)
    if err != nil {
        panic(err)
    }
    err = terra.NewTransaction(querier).
        Message(func() (cosmos.Msg, error) {
            return anc.Market.NewDepositUSTMessage(wallet.Address(), decimal.NewFromInt(100))
        }).
        ExecuteAndWaitFor(ctx, wallet)
	
	

GitHub

View Github