diff --git a/web3.js/src/connection.ts b/web3.js/src/connection.ts index 36d4b8b74310eb..0ca11c9ee4e846 100644 --- a/web3.js/src/connection.ts +++ b/web3.js/src/connection.ts @@ -4278,6 +4278,27 @@ export class Connection { } } + /** + * get the stake minimum delegation + */ + async getStakeMinimumDelegation(): Promise> { + const config: any = { + encoding: 'base64', + commitment: this.commitment, + }; + const unsafeRes = await this._rpcRequest('getStakeMinimumDelegation', [ + config, + ]); + const res = create(unsafeRes, jsonRpcResultAndContext(number())); + if ('error' in res) { + throw new SolanaJSONRPCError( + res.error, + `failed to get stake minimum delegation`, + ); + } + return res.result; + } + /** * Simulate a transaction */ diff --git a/web3.js/test/connection.test.ts b/web3.js/test/connection.test.ts index c6e85a557e443f..437c6ce2c590bd 100644 --- a/web3.js/test/connection.test.ts +++ b/web3.js/test/connection.test.ts @@ -3804,6 +3804,10 @@ describe('Connection', function () { } if (process.env.TEST_LIVE) { + it('getStakeMinimumDelegation', async () => { + const {value} = await connection.getStakeMinimumDelegation(); + expect(value).to.eql(1000000000); + }); it('simulate transaction with message', async () => { connection._commitment = 'confirmed'; diff --git a/web3.js/test/stake-program.test.ts b/web3.js/test/stake-program.test.ts index f7bfee32715620..a0f23bcb424a85 100644 --- a/web3.js/test/stake-program.test.ts +++ b/web3.js/test/stake-program.test.ts @@ -387,8 +387,9 @@ describe('StakeProgram', () => { const STAKE_ACCOUNT_MIN_BALANCE = await connection.getMinimumBalanceForRentExemption(StakeProgram.space); - // todo: use `Connection.getMinimumStakeDelegation` when implemented - const MIN_STAKE_DELEGATION = LAMPORTS_PER_SOL; + const MIN_STAKE_DELEGATION = ( + await connection.getStakeMinimumDelegation() + ).value; const voteAccounts = await connection.getVoteAccounts(); const voteAccount = voteAccounts.current.concat(