Skip to content

Commit c10a9e5

Browse files
committed
chore(SOLNENG-27): embed blockdaemon docs links
1 parent 79d521a commit c10a9e5

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

solana-staking/buildervault/nodejs/solana-stake-bv.ts

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ async function main() {
5454
throw new Error('SOLANA_VALIDATOR_ADDRESS environment variable not set');
5555
}
5656

57-
// Set buildervault endpoints
57+
// * BuilderVault mTLS authentication with publickey pinning: https://builder-vault-tsm.docs.blockdaemon.com/docs/authentication-3#public-key-pinning
5858

5959
const serverMtlsPublicKeys = {
6060
0: `-----BEGIN CERTIFICATE-----\nMIICMTCCAdegAwIBAgICB+MwCgYIKoZIzj0EAwIwgaAxCzAJBgNVBAYTAlVTMRMw\nEQYDVQQIDApDYWxpZm9ybmlhMRQwEgYDVQQHDAtMb3MgQW5nZWxlczEUMBIGA1UE\nCgwLQmxvY2tkYWVtb24xFDASBgNVBAsMC0Jsb2NrZGFlbW9uMRQwEgYDVQQDDAtC\nbG9ja2RhZW1vbjEkMCIGCSqGSIb3DQEJARYVYWRtaW5AYmxvY2tkYWVtb24uY29t\nMB4XDTI0MDIxMzE3MjE0OFoXDTI5MDIxMzE3MjE0OFowTjELMAkGA1UEBhMCVVMx\nEzARBgNVBAgTCkNhbGlmb3JuaWExFDASBgNVBAcTC0xvcyBBbmdlbGVzMRQwEgYD\nVQQKEwtCbG9ja2RhZW1vbjBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABGlixcUc\nYC0ByeutoHHdi3zxWCg5iPAJcxVLvzBUdD2+XdCWEgS/xwFEef9Tl3xFdfK4iWSQ\nnjmtYMTaHMM6mfWjUjBQMA4GA1UdDwEB/wQEAwIHgDAdBgNVHSUEFjAUBggrBgEF\nBQcDAgYIKwYBBQUHAwEwHwYDVR0jBBgwFoAUW6ouasv5oWo7MZ4ZzlE/mpbDrIMw\nCgYIKoZIzj0EAwIDSAAwRQIgSDKHZmsnylzL8kopFSeo8L6LQGxyd/NsBRb+8STI\n1cECIQChi4cl5nJgTXCBzJEHicnRk/0vl+9zq6iABMV+KTXJxA==\n-----END CERTIFICATE-----`,
@@ -109,9 +109,9 @@ async function main() {
109109
const delegatorAddress = new web3.PublicKey(bs58.encode(compressedPublicKey));
110110
console.log(`Solana address of derived key m/44/501: ${delegatorAddress}\n`);
111111

112+
// * Using Blockdaemon RPC API for Solana: https://docs.blockdaemon.com/reference/how-to-access-solana-api
112113

113-
//const connection = new web3.Connection(`https://svc.blockdaemon.com/solana/${process.env.SOLANA_NETWORK}/native?apiKey=${process.env.BLOCKDAEMON_API_KEY}`, "confirmed");
114-
const connection = new web3.Connection(`https://api.${process.env.SOLANA_NETWORK}.solana.com`, "confirmed"); // Todo: change to svc.blockdaemon.com when websockets is supported
114+
const connection = new web3.Connection(`https://svc.blockdaemon.com/solana/${process.env.SOLANA_NETWORK}/native?apiKey=${process.env.BLOCKDAEMON_API_KEY}`, "confirmed");
115115

116116
// Check if validator exists
117117
const voteAccounts = await connection.getVoteAccounts('finalized');
@@ -120,7 +120,7 @@ async function main() {
120120
throw "Validator address is not part of the active validators in the network";
121121
}
122122

123-
// Create a stake intent with the Staking Integration API
123+
// * Create a stake intent with the Staking Integration API: https://docs.blockdaemon.com/reference/postsolanastakeintent
124124

125125
const response = await createStakeIntent(process.env.BLOCKDAEMON_STAKE_API_KEY, {
126126
amount: amountLamports.toString(),
@@ -160,15 +160,8 @@ async function main() {
160160
// Broadcast the transaction
161161

162162
console.log(`Full signed transaction base64: ${transaction.serialize().toString("base64")}\n`);
163-
const latestBlockhash = await connection.getLatestBlockhash();
164-
const txid = await web3.sendAndConfirmRawTransaction(connection, transaction.serialize(),
165-
{
166-
signature: bs58.encode(signature),
167-
blockhash: latestBlockhash.blockhash,
168-
lastValidBlockHeight: latestBlockhash.lastValidBlockHeight,
169-
})
170-
171-
console.log(`Confirmed transaction: https://explorer.solana.com/tx/${txid}/?cluster=${process.env.SOLANA_NETWORK}`)
163+
const txid = await connection.sendRawTransaction(transaction.serialize());
164+
console.log(`Broadcasted transaction: https://explorer.solana.com/tx/${txid}/?cluster=${process.env.SOLANA_NETWORK}`)
172165
}
173166

174167

@@ -208,6 +201,7 @@ async function signTx(
208201
chainPath: Uint32Array
209202
): Promise<any> {
210203

204+
// * Builder Vault signing operation: https://builder-vault-tsm.docs.blockdaemon.com/docs/key-generation-and-signing#signing
211205

212206
console.log(`Builder Vault signing transaction hash...`);
213207

@@ -315,6 +309,8 @@ async function getKeyId(
315309
// clients.length
316310
// );
317311

312+
// * Builder Vault Key Generation: https://builder-vault-tsm.docs.blockdaemon.com/docs/key-generation-and-signing#key-generation
313+
318314
const masterKeyIds: string[] = [];
319315

320316
clients.forEach(() => masterKeyIds.push(""));

0 commit comments

Comments
 (0)