Skip to content

Instantly share code, notes, and snippets.

View larry0x's full-sized avatar
🇵🇹
PT

Larry larry0x

🇵🇹
PT
View GitHub Profile
@larry0x
larry0x / go.mod
Last active February 12, 2024 18:39
How to use RocksDB's user-defined timestamp feature in Go
module playground
go 1.21
require github.com/linxGnu/grocksdb v1.8.4

Configure gpg signing (importing an existing private key):

git config --global user.name 'your-name'
git config --global user.email 'your-email'
git config --global user.signingkey 'your-gpg-pubkey'
git config --global commit.gpgsign true
git config --global --list

sudo apt install gpg
@larry0x
larry0x / cw-sdk-bank-contract.md
Last active August 25, 2023 23:26
CW-SDK bank contract

CW-SDK's bank contract will manage both fungible and nonfungible tokens.

  • Each fungible token is identified by a denom
  • Each nonfungible token is identified by a tuple (denom, sequence) where sequence is a u64; the 1st token in the collection gets a sequence of 0, the 2nd gets 1, so on

An NFT collection cannot share the same denom with a fungible token.

struct Coin {
    pub denom:  String,
{
"genesis_time": "2023-05-23T00:00:00.000000Z",
"chain_id": "dev-1",
"initial_height": "1",
"consensus_params": {
"block": {
"max_bytes": "22020096",
"max_gas": "-1"
},
"evidence": {
#!/bin/bash
# Some helper functions for working with cosmos-sdk txs from the command line or
# in bash scripts.
#
# Example: say, if you want to send coins to multiple recipients. We need to:
#
# - compose a tx containing multiple "send" messages
# - set an appropriate gas limit and fee amount
# - sign it
# update ubuntu packages
sudo apt update && sudo apt upgrade -y && sudo apt autoremove -y
# update rust
rustup update
rustc -V
# update cargo global dependencies
# dependencies:
# sudo apt install build-essential libssl-dev wget pkg-config
//! ```cargo
//! [dependencies]
//! chrono = "0.4"
//! csv = "1"
//! ethers = "2"
//! reqwest = { version = "0.11", features = ["json"] }
//! rustc-hex = "2"
//! serde = "1"
//! thiserror = "1"
//! tokio = { version = "1", features = ["full"] }
@larry0x
larry0x / json-raw-message-to-sdk-msg.go
Created June 16, 2023 03:37
json.RawMessage to sdk.Msg
package main
import (
"encoding/json"
"fmt"
"reflect"
"cosmossdk.io/simapp"
"github.com/cosmos/cosmos-sdk/codec"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
//! ```cargo
//! [dependencies]
//! bech32 = "0.9"
//! bip32 = "0.5"
//! dialoguer = "0.10"
//! hex = "0.4"
//! k256 = "0.13"
//! ripemd = "0.1"
//! thiserror = "1"
//! ```

The data field in cosmwasm_std::Response is underused. We should use it more! Here's why.

Often we want to program contracts that do this:

  1. call another contract
  2. after the call is completed, handle the response and do some extra actions

For example,

  1. swap some token A to token B at Astroport