2021-07-07 05:29:22 -07:00
|
|
|
// Copyright 2020 dfuse Platform Inc.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
package rpc
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"github.com/gagliardetto/solana-go"
|
|
|
|
)
|
|
|
|
|
|
|
|
// RequestAirdrop requests an airdrop of lamports to a publicKey.
|
2021-07-19 12:57:25 -07:00
|
|
|
// Returns transaction signature of airdrop.
|
2021-07-07 05:29:22 -07:00
|
|
|
func (cl *Client) RequestAirdrop(
|
|
|
|
ctx context.Context,
|
|
|
|
account solana.PublicKey,
|
2021-07-27 07:24:08 -07:00
|
|
|
lamports uint64,
|
2021-07-19 12:57:25 -07:00
|
|
|
commitment CommitmentType, // optional; used for retrieving blockhash and verifying airdrop success.
|
2021-07-07 05:29:22 -07:00
|
|
|
) (signature solana.Signature, err error) {
|
|
|
|
params := []interface{}{
|
|
|
|
account,
|
2021-07-27 07:24:08 -07:00
|
|
|
lamports,
|
2021-07-07 05:29:22 -07:00
|
|
|
}
|
|
|
|
if commitment != "" {
|
|
|
|
params = append(params,
|
|
|
|
M{"commitment": commitment},
|
|
|
|
)
|
|
|
|
}
|
2021-07-20 12:29:06 -07:00
|
|
|
err = cl.rpcClient.CallForInto(ctx, &signature, "requestAirdrop", params)
|
2021-07-07 05:29:22 -07:00
|
|
|
return
|
|
|
|
}
|