query stake address like this:
cardano-cli shelley query stake-address-info --address [stake-address] --mainnet
build withdraw transaction like this:
cardano-cli shelley transaction build-raw \
–tx-in [utxo]#[TxIx] \
–tx-out [destination address]+[rewards-amount] \
–tx-out [payment.addr]+[lovelaces-remaining-in-payment.add] \
–fee [tx-fee] \
–ttl [current-slot + 100000] \
–withdrawal [stake-address]+[rewards-amount] \
–out-file rewards.raw