forked from solana-labs/solana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update -- use method instead of timer, which is more performant
- Loading branch information
Showing
3 changed files
with
192 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import * as web3 from '@solana/web3.js'; | ||
|
||
(async () => { | ||
// Connect to cluster | ||
var connection = new web3.Connection( | ||
web3.clusterApiUrl('devnet'), | ||
'confirmed', | ||
); | ||
|
||
// Generate a new wallet keypair and airdrop SOL | ||
var wallet1 = web3.Keypair.generate(); | ||
var airdropSignature = await connection.requestAirdrop( | ||
wallet1.publicKey, | ||
web3.LAMPORTS_PER_SOL, | ||
); | ||
|
||
//wait for airdrop confirmation | ||
await connection.confirmTransaction(airdropSignature); | ||
|
||
// Generate a new wallet keypair and airdrop SOL | ||
var wallet2 = web3.Keypair.generate(); | ||
var airdropSignature2 = await connection.requestAirdrop( | ||
wallet2.publicKey, | ||
web3.LAMPORTS_PER_SOL, | ||
); | ||
|
||
//wait for airdrop confirmation | ||
await connection.confirmTransaction(airdropSignature); | ||
|
||
// get both accounts' info through a single JSON RPC batch transaction | ||
// account data is bytecode that needs to be deserialized | ||
// serialization and deserialization is program specific | ||
let [account1, account2] = await connection.performBatchRequest([ | ||
() => connection.getAccountInfo(wallet1.publicKey), | ||
() => connection.getAccountInfo(wallet2.publicKey) | ||
]); | ||
console.log(account1, account2); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters