3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

はじめに

ちょっと仕事で疲れたので、Rustでlessコマンド実装は一旦お休みして、軽めのネタでSolanaを触ってみます。

Solanaの特徴とかはあんまりわかってません。
なんとなくEthereumコントラクト的なことがさっくりできる、みたいなイメージだけあります。

ちなみに主な実装はRustみたいです。

環境

Rust 1.57 stable
MacOSX 11.6 (Intel Mac)
Solana(CLI) solana-cli 1.8.6 (src:e5aa5efb; feat:591501692)

インストール

CLIインストールから

$ sh -c "$(curl -sSfL https://release.solana.com/v1.8.6/install)"

Zsh補完関数設定しておく。

$ solana completion -s zsh > ~/.zsh/completions/_solana

鍵をつくる

CLI使うのに必要そうなので、とりあえず鍵作ってみる。
テストようなので後でまるっと削除する予定。

$ mkdir $HOME/.solana
$ solana-keygen new --outfile ~/.solana/test-keypair.json
Generating a new keypair

For added security, enter a BIP39 passphrase

NOTE! This passphrase improves security of the recovery seed phrase NOT the
keypair file itself, which is stored as insecure plain text

BIP39 Passphrase (empty for none):

Wrote new keypair to ~/.solana/test-keypair.json
======================================================================================
pubkey: DmAUUA2Rw1yXhstczJgRQYXBB3GrsesUhTvSVkzGfWWe
======================================================================================
Save this seed phrase and your BIP39 passphrase to recover your new keypair:
tourist squeeze hungry strategy engage visa cake erupt display disorder stand describe
======================================================================================
$ solana-keygen verify DmAUUA2Rw1yXhstczJgRQYXBB3GrsesUhTvSVkzGfWWe ~/.solana/test-keypair.json
Verification for public key: DmAUUA2Rw1yXhstczJgRQYXBB3GrsesUhTvSVkzGfWWe: Success

Devnetにつないでみる

上記見るとDevnetは開発用のネットワークの模様。

  • Mainnet Beta
  • Testnet
  • Devnet

の3つが主に使われている。まぁ名前で大体の役割はわかる。

ネットワーク接続用に設定ファイルを作る。

$ solana config get
Config File: ~/.config/solana/cli/config.yml
RPC URL: https://api.mainnet-beta.solana.com
WebSocket URL: wss://api.mainnet-beta.solana.com/ (computed)
Keypair Path: ~/.config/solana/id.json
Commitment: confirmed

Devnet使うように設定更新。

$ solana config set --url https://api.devnet.solana.com
Config File: ~/.config/solana/cli/config.yml
RPC URL: https://api.devnet.solana.com
WebSocket URL: wss://api.devnet.solana.com/ (computed)
Keypair Path: ~/.config/solana/id.json
Commitment: confirmed

SOL Tokenの送受信

以下見ればできる。

$ solana airdrop 1 DmAUUA2Rw1yXhstczJgRQYXBB3GrsesUhTvSVkzGfWWe
Requesting airdrop of 1 SOL

Signature: 4izfAa1nzsN7nXhf3uGapZnDYFijW1rPFDbLW19AgyRFqQT3zb9A9JvFvv3n2vAz2E6NsEkXoRyELtTtH6GPp8HS

1 SOL
$ solana balance DmAUUA2Rw1yXhstczJgRQYXBB3GrsesUhTvSVkzGfWWe
1 SOL
$ solana-keygen new --no-passphrase --no-outfile
Generating a new keypair
===================================================================================
pubkey: DMfsu7nKhyrSYPN2MWyUCYDxLAFcXJBdeNjkLoj73Rwn
===================================================================================
Save this seed phrase to recover your new keypair:
extra execute black skull rather hedgehog digital arch unfold endless catalog learn
===================================================================================
$ solana transfer --from ~/.solana/test-keypair.json DMfsu7nKhyrSYPN2MWyUCYDxLAFcXJBdeNjkLoj73Rwn 0.5 --allow-unfunded-recipient --fee-payer ~/.solana/test-keypair.json

Signature: 4g4XiggUqk93WnVai7BdecjoVfe7QTCe27NJqPmrXzUtkSm8J6Y9kK1FrmPM8hCeJn6nWq2nd8V9zUsEqegPFG8m
$ solana balance DmAUUA2Rw1yXhstczJgRQYXBB3GrsesUhTvSVkzGfWWe
0.499995 SOL
$ solana balance DMfsu7nKhyrSYPN2MWyUCYDxLAFcXJBdeNjkLoj73Rwn
0.5 SOL

ここでトランザクション見れる。

特に引っ掛かりポイントもなくサクサク進む。ドキュメントも整ってるしいい感じ。
ということで今日はここまで。

参考

3
1
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?