# Distribute Solana tokens
A user may want to make payments to multiple accounts over multiple iterations.
The user will have a spreadsheet listing public keys and token amounts, and
some process for transferring tokens to them, and ensuring that no more than the
expected amount are sent. The command-line tool here automates that process.
## Distribute tokens
Send tokens to the recipients in `<RECIPIENTS_CSV>`.
Example recipients.csv:
```text
recipient,amount,lockup_date
3ihfUy1n9gaqihM5bJCiTAGLgWc5zo3DqVUS6T736NLM,42.0,
CYRJWqiSjLitBAcRxPvWpgX3s5TvmN2SuRY3eEYypFvT,43.0,
```
```bash
solana-tokens distribute-tokens --from <KEYPAIR> --input-csv <RECIPIENTS_CSV> --fee-payer <KEYPAIR>
```
Example transaction log before:
```text
recipient,amount,finalized_date,signature
6Vo87BaDhp4v4GHwVDhw5huhxVF8CyxSXYtkUwVHbbPv,70.0,2020-09-15T23:29:26.879747Z,UB168XhBhecxzeD1w2ZRUhwTHpPSqv2WNh8NrZHqz1F2EqxxbSW6iFfVtsg3HkU9NX2cD7R92D8VRLSyArZ9xKQ
```
Send tokens to the recipients in `<RECIPIENTS_CSV>` if the distribution is
not already recorded in the transaction log.
```bash
solana-tokens distribute-tokens --from <KEYPAIR> --input-csv <RECIPIENTS_CSV> --fee-payer <KEYPAIR>
```
Example output:
```text
Recipient Expected Balance
3ihfUy1n9gaqihM5bJCiTAGLgWc5zo3DqVUS6T736NLM 42
UKUcTXgbeTYh65RaVV5gSf6xBHevqHvAXMo3e8Q6np8k 43
```
Example transaction log after:
```bash
solana-tokens transaction-log --output-path transactions.csv
```
```text
recipient,amount,signature
6Vo87BaDhp4v4GHwVDhw5huhxVF8CyxSXYtkUwVHbbPv,70.0,2020-09-15T23:29:26.879747Z,UB168XhBhecxzeD1w2ZRUhwTHpPSqv2WNh8NrZHqz1F2EqxxbSW6iFfVtsg3HkU9NX2cD7R92D8VRLSyArZ9xKQ
3ihfUy1n9gaqihM5bJCiTAGLgWc5zo3DqVUS6T736NLM,42.0,2020-09-15T23:31:50.264241Z,53AVNEVpQBteJBRAKp6naxXsgESDjqe1ge9Dg2HeCSpYWTuGTLqHrBpkHTnpvPJURNgKWxkJfihuRa5STVRjL2hy
CYRJWqiSjLitBAcRxPvWpgX3s5TvmN2SuRY3eEYypFvT,43.0,2020-09-15T23:33:53.680821Z,4XsMfLx9D2ZxVpdJ5xdkV2w4X4SKEQ5zbQhcH4NcRwgZDkdRNiZjvnMFaWaWHUh5eF1LwFPpQdjn6mzSsiCVj3L7
```
### Calculate what tokens should be sent
List the differences between a list of expected distributions and the record of what
transactions have already been sent.
```bash
solana-tokens distribute-tokens --dry-run --input-csv <RECIPIENTS_CSV>
```
Example recipients.csv:
```text
recipient,amount,lockup_date
6Vo87BaDhp4v4GHwVDhw5huhxVF8CyxSXYtkUwVHbbPv,80,
7aHDubg5FBYj1SgmyBgU3ZJdtfuqYCQsJQK2pTR5JUqr,42,
```
Example output:
```text
Recipient Expected Balance
6Vo87BaDhp4v4GHwVDhw5huhxVF8CyxSXYtkUwVHbbPv 10
7aHDubg5FBYj1SgmyBgU3ZJdtfuqYCQsJQK2pTR5JUqr 42
```
## Distribute tokens: transfer-amount
This tool also makes it straightforward to transfer the same amount of tokens to a simple list of recipients. Just add the `--transfer-amount` arg to specify the amount:
Example recipients.csv:
```text
recipient
6Vo87BaDhp4v4GHwVDhw5huhxVF8CyxSXYtkUwVHbbPv
7aHDubg5FBYj1SgmyBgU3ZJdtfuqYCQsJQK2pTR5JUqr
CYRJWqiSjLitBAcRxPvWpgX3s5TvmN2SuRY3eEYypFvT
```
```bash
solana-tokens distribute-tokens --transfer-amount 10 --from <KEYPAIR> --input-csv <RECIPIENTS_CSV> --fee-payer <KEYPAIR>
```
Example output:
```text
Recipient Expected Balance
6Vo87BaDhp4v4GHwVDhw5huhxVF8CyxSXYtkUwVHbbPv 10
7aHDubg5FBYj1SgmyBgU3ZJdtfuqYCQsJQK2pTR5JUqr 10
CYRJWqiSjLitBAcRxPvWpgX3s5TvmN2SuRY3eEYypFvT 10
```
## Distribute stake accounts
Distributing tokens via stake accounts works similarly to how tokens are distributed. The
big difference is that new stake accounts are split from existing ones. By splitting,
the new accounts inherit any lockup or custodian settings of the original.
```bash
solana-tokens distribute-stake --stake-account-address <ACCOUNT_ADDRESS> \
--input-csv <ALLOCATIONS_CSV> \
--stake-authority <KEYPAIR> --withdraw-authority <KEYPAIR> --fee-payer <KEYPAIR>
```
Currently, this will subtract 1 SOL from each allocation and store it in the
recipient address. That SOL can be used to pay transaction fees on staking
operations such as delegating stake. The rest of the allocation is put in
a stake account. The new stake account address is output in the transaction
log.
## Distribute SPL tokens
Distributing SPL Tokens works very similarly to distributing SOL, but requires
the `--owner` parameter to sign transactions. Each recipient account must be an
system account that will own an Associated Token Account for the SPL Token mint.
The Associated Token Account will be created, and funded by the fee_payer, if it
does not already exist.
Send SPL tokens to the recipients in `<RECIPIENTS_CSV>`.
*NOTE:* the CSV expects SPL-token amounts in raw format (no decimals)
Example recipients.csv:
```text
recipient,amount
CYRJWqiSjLitBAcRxPvWpgX3s5TvmN2SuRY3eEYypFvT,75400
C56nwrDVFpPrqwGYsTgQxv1ZraTh81H14PV4RHvZe36s,10000
7aHDubg5FBYj1SgmyBgU3ZJdtfuqYCQsJQK2pTR5JUqr,42100
7qQPmVAQxEQ5djPDCtiEUrxaPf8wKtLG1m6SB1brejJ1,20000
```
You can check the status of the recipients before beginning a distribution. You
must include the SPL Token mint address:
```bash
solana-tokens spl-token-balances --mint <ADDRESS> --input-csv <RECIPIENTS_CSV>
```
Example output:
```text
Token: JDte736XZ1jGUtfAS32DLpBUWBR7WGSHy1hSZ36VRQ5V
Recipient Expected Balance Actual Balance Difference
CYRJWqiSjLitBAcRxPvWpgX3s5TvmN2SuRY3eEYypFvT 75.400 0.000 -75.400
C56nwrDVFpPrqwGYsTgQxv1ZraTh81H14PV4RHvZe36s 10.000 Associated token account not yet created
7aHDubg5FBYj1SgmyBgU3ZJdtfuqYCQsJQK2pTR5JUqr 42.100 0.000 -42.100
7qQPmVAQxEQ5djPDCtiEUrxaPf8wKtLG1m6SB1brejJ1 20.000 Associated token account not yet created
```
To run the distribution:
```bash
solana-tokens distribute-spl-tokens --from <ADDRESS> --owner <KEYPAIR> \
--input-csv <RECIPIENTS_CSV> --fee-payer <KEYPAIR>
```
Example output:
```text
Total in input_csv: 147.5 tokens
Distributed: 0 tokens
Undistributed: 147.5 tokens
Total: 147.5 tokens
Recipient Expected Balance
CYRJWqiSjLitBAcRxPvWpgX3s5TvmN2SuRY3eEYypFvT 75.400
C56nwrDVFpPrqwGYsTgQxv1ZraTh81H14PV4RHvZe36s 10.000
7aHDubg5FBYj1SgmyBgU3ZJdtfuqYCQsJQK2pTR5JUqr 42.100
7qQPmVAQxEQ5djPDCtiEUrxaPf8wKtLG1m6SB1brejJ1 20.000
```
### Calculate what tokens should be sent
As with SOL, you can List the differences between a list of expected
distributions and the record of what transactions have already been sent using
the `--dry-run` parameter, or `solana-tokens balances`.
Example updated recipients.csv:
```text
recipient,amount
CYRJWqiSjLitBAcRxPvWpgX3s5TvmN2SuRY3eEYypFvT,100000
C56nwrDVFpPrqwGYsTgQxv1ZraTh81H14PV4RHvZe36s,100000
7aHDubg5FBYj1SgmyBgU3ZJdtfuqYCQsJQK2pTR5JUqr,100000
7qQPmVAQxEQ5djPDCtiEUrxaPf8wKtLG1m6SB1brejJ1,100000
```
Using dry-run:
```bash
solana-tokens distribute-tokens --dry-run --input-csv <RECIPIENTS_CSV>
```
Example output:
```text
Total in input_csv: 400 tokens
Distributed: 147.5 tokens
Undistributed: 252.5 tokens
Total: 400 tokens
Recipient Expected Balance
CYRJWqiSjLitBAcRxPvWpgX3s5TvmN2SuRY3eEYypFvT 24.600
C56nwrDVFpPrqwGYsTgQxv1ZraTh81H14PV4RHvZe36s 90.000
7aHDubg5FBYj1SgmyBgU3ZJdtfuqYCQsJQK2pTR5JUqr 57.900
7qQPmVAQxEQ5djPDCtiEUrxaPf8wKtLG1m6SB1brejJ1 80.000
```
Or:
```bash
solana-tokens balances --mint <ADDRESS> --input-csv <RECIPIENTS_CSV>
```
Example output:
```text
Token: JDte736XZ1jGUtfAS32DLpBUWBR7WGSHy1hSZ36VRQ5V
Recipient Expected Balance Actual Balance Difference
CYRJWqiSjLitBAcRxPvWpgX3s5TvmN2SuRY3eEYypFvT 100.000 75.400
没有合适的资源?快使用搜索试试~ 我知道了~
用于快速、安全、可扩展、去中心化应用程序和市场的 Web-Scale 区块链
共2000个文件
rs:1009个
sh:227个
md:155个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 37 浏览量
2024-05-06
09:48:48
上传
评论
收藏 15.47MB ZIP 举报
温馨提示
用于快速、安全、可扩展、去中心化应用程序和市场的 Web-Scale 区块链。
资源推荐
资源详情
资源评论
收起资源包目录
用于快速、安全、可扩展、去中心化应用程序和市场的 Web-Scale 区块链 (2000个子文件)
_ 309B
decode_u32_precomputation_for_G.bincode 2.13MB
retransmit_stage.bob 4KB
tvu.bob 4KB
validator-proposal.bob 3KB
validator.bob 2KB
tpu.bob 1KB
spv-block-merkle.bob 1KB
spv-bank-hash.bob 1KB
sdk-tools.bob 1KB
fork-generation.bob 820B
runtime.bob 685B
transaction.bob 568B
forks.bob 145B
forks-pruned.bob 57B
forks-pruned2.bob 54B
invoke.c 33KB
poseidon.c 12KB
invoked.c 10KB
alt_bn128.c 6KB
dup_accounts.c 3KB
sha.c 3KB
alt_bn128.c 2KB
secp256k1_recover.c 2KB
big_mod_exp.c 2KB
alloc.c 2KB
tuner.c 1KB
error_handling.c 1KB
tuner-variable-iterations.c 1KB
ser.c 1021B
move_funds.c 987B
float.c 934B
return_data.c 910B
log_data.c 766B
deprecated_loader.c 697B
sanity.c 660B
stdlib.c 625B
bench_alu.c 589B
read_program.c 579B
struct_ret.c 511B
remaining_compute_units.c 482B
noop_unaligned.c 423B
struct_pass.c 381B
noop_aligned.c 377B
noop.c 377B
relative_call.c 276B
entrypoint.c 272B
multiple_static.c 249B
test_bench_alu.c 234B
panic.c 204B
helper.c 190B
cargo 685B
cargo-build-bpf 533B
cargo-build-sbf 402B
cargo-test-bpf 569B
cargo-test-sbf 309B
sanity++.cc 712B
noop++.cc 373B
colo_nodes 70B
complete-loss-four-partitions 1KB
complete-loss-two-partitions 277B
influxdb.conf 3KB
katex.css 25KB
katex.min.css 22KB
custom.css 7KB
styles.module.css 633B
copy-tex.css 461B
styles.module.css 308B
copy-tex.min.css 104B
Dockerfile 5KB
Dockerfile 641B
.eslintignore 85B
.eslintrc 512B
.gitignore 496B
.gitignore 387B
.gitignore 298B
.gitignore 268B
.gitignore 57B
.gitignore 50B
.gitignore 40B
.gitignore 37B
.gitignore 35B
.gitignore 34B
.gitignore 20B
.gitignore 20B
.gitignore 16B
.gitignore 16B
.gitignore 16B
.gitignore 16B
.gitignore 16B
.gitignore 16B
.gitignore 16B
.gitignore 16B
.gitignore 16B
.gitignore 16B
.gitignore 16B
.gitignore 16B
.gitignore 16B
.gitignore 16B
.gitignore 16B
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
sjx_alo
- 粉丝: 1w+
- 资源: 1216
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功