The title is pretty much it. Can I use Polkadot API to stake dot programmatically?
Can't seem to find that in the docs.
Substrate and Polkadot Stack Exchange is a question and answer site for developers building blockchains with the Substrate SDK. It only takes a minute to sign up.
Sign up to join this communityYes, of course.
You can read the documentation to learn how to submit extrinsics using Polkadot JS API:
https://polkadot.js.org/docs/api/start/api.tx
Then, you just need to submit two extrinsics from the Staking Pallet:
Bond: https://paritytech.github.io/substrate/master/pallet_staking/pallet/enum.Call.html#variant.bond
This will lock a users funds so they can start to stake as a validator or nominator.
Either:
Nominate: https://paritytech.github.io/substrate/master/pallet_staking/pallet/enum.Call.html#variant.nominate
If you want to set up the account as a nominator.
Validate: https://paritytech.github.io/substrate/master/pallet_staking/pallet/enum.Call.html#variant.validate
If you want to set up the account as a validator.
There are more details needed specifically if you are setting up to be a validator which you can learn about here: https://wiki.polkadot.network/docs/maintain-guides-how-to-validate-polkadot