# How to withdraw staked JUNO from cancelled vesting contracts
1. Get the addresses of the cancelled vesting contracts you want to withdraw from
(#TODO what's the best way?)
2. Get the delegations for each of your contracts with a query to one of the network nodes (on which you have RPC access):
`junod q staking delegations [delegator_address] --node [node_address:port]`
where `delegator_address` is your vesting contract address, for example:
```
junod q staking delegations juno10uwjkshv6fe3u3wqvy3dpv6ny0f06kqgtf526jx4ln8e69lcwzwqrjtsa5 --node https://rpc-juno.mib.tech:443 | jq
```
(#TODO is there a better way?)
Note that the `| jq` at the end only transforms the output of the command for better readability, by using the [Jqlang/jq Command-line JSON processor](https://jqlang.github.io/jq/download/).
2. Check that `delegation_responses.delegation.delegator_address` corresponds to your DAO address
4. Copy the `validator_address` and `amount` values
5. Create a proposal and add the **Execute Smart Contract** action for every delegation you want to withdraw from, like:
1. Contract 1 example:
1. Delegation 1:
1. **Smart contract address** = `juno10uwjkshv6fe3u3wqvy3dpv6ny0f06kqgtf526jx4ln8e69lcwzwqrjtsa5`
2. **Message** = `{"undelegate": {"amount": "79976002443","validator": "junovaloper175q6smvgnuec5e62rs4chnu5cs8d98q2e4l6cl”}}`
2. Delegation 2:
1. `juno10uwjkshv6fe3u3wqvy3dpv6ny0f06kqgtf526jx4ln8e69lcwzwqrjtsa5`
2. `{"undelegate": {"amount": "199996000017","validator": "junovaloper185hgkqs8q8ysnc8cvkgd8j2knnq2m0ah6ae73gntv9ampgwpmrxqlfzywn”}}`
2. Contract 2 example:
1. Delegation 2:
1. `juno1vy2axld4mak0yxmx4eqglkfcrn5aj3qy5sm5run5kmcjmn07askqrh009y`
2. `{"undelegate": {"amount": "199996000017","validator": "junovaloper1gp957czryfgyvxwn3tfnyy2f0t9g2p4pvzc6k3”}}`
2. Delegation 3:
1. `juno1vy2axld4mak0yxmx4eqglkfcrn5aj3qy5sm5run5kmcjmn07askqrh009y`
2. `{"undelegate": {"amount": "50000000000","validator": "junovaloper1wd02ktcvpananlvd9u6jm3x3ap3vmw59jv9vez”}}`
3. Delegation 4:
1. `juno1vy2axld4mak0yxmx4eqglkfcrn5aj3qy5sm5run5kmcjmn07askqrh009y`
2. `{"undelegate": {"amount": "44415058013","validator": "junovaloper1sgghjqdrj9kujkx38q04d99qsljwfd6mxyrssk”}}`
3. Contract 3 example:
1. Delegation 5:
1. `juno1a4pjj5l4szl7kq8u4h07se3675fsqcfh66vtks7hlckgz2kpaq0ssn309f`
2. `{"undelegate": {"amount": "127334500000","validator": "junovaloper1t8ehvswxjfn3ejzkjtntcyrqwvmvuknzmvtaaa”}}`
2. Delegation 6:
1. `juno1a4pjj5l4szl7kq8u4h07se3675fsqcfh66vtks7hlckgz2kpaq0ssn309f`
2. `{"undelegate": {"amount": "127309034443","validator": "junovaloper1j9644d7qyln8smd2t42jvymj0yhjw5qkmw9fms”}}`
4. Contract 4 example:
1. Delegation 7:
1. `juno1ajs39qk0kd5xcjc8lvsym9q9g8q5jalzreum7nwqg036mqrw7utqf9gsu4`
2. `{"undelegate": {"amount": "134980000015","validator": "junovaloper1dru5985k4n5q369rxeqfdsjl8ezutch8mc6nx9”}}`
2. Delegation 8:
1. `juno1ajs39qk0kd5xcjc8lvsym9q9g8q5jalzreum7nwqg036mqrw7utqf9gsu4`
2. `{"undelegate": {"amount": "145000000007","validator": "junovaloper1j9644d7qyln8smd2t42jvymj0yhjw5qkmw9fms”}}`
6. Note that there is a bug in Cosmos SDK which could show some delegations with `amount` = `0` but `shares` > `0`: those delegation records won't be withdrawable so you can ignore them. (#TBR #OnChainUpgrade).
7. Publish, vote and execute the proposal.
8. Wait for the unstaking period (currently 4 weeks for Juno) so that funds become available.
9. Get the amount of JUNO **available** at the address of the vesting contract:
- by using the `junod q bank balances` query method on the command-line,
- or by visiting the respective *address* or *account* page on an explorer, like `mintscan.io/juno/address/juno10uwjkshv6fe3u3wqvy3dpv6ny0f06kqgtf526jx4ln8e69lcwzwqrjtsa5` or `ping.pub/juno/account/juno10uwjkshv6fe3u3wqvy3dpv6ny0f06kqgtf526jx4ln8e69lcwzwqrjtsa5`
10. Create a proposal and add the **Execute Smart Contract** action for every vesting contract you're withdrawing from, with:
1. Contract 1 example:
1. **Smart contract address** = `juno10uwjkshv6fe3u3wqvy3dpv6ny0f06kqgtf526jx4ln8e69lcwzwqrjtsa5`
2. **Message** = `{ "withdraw_canceled_payment": { "amount": "[to_fill]"}}`
2. Contract 2 example:
1. `juno1vy2axld4mak0yxmx4eqglkfcrn5aj3qy5sm5run5kmcjmn07askqrh009y`
2. `{ "withdraw_canceled_payment": { "amount": "[to_fill]"}}`
3. Contract 3 example:
1. `juno1a4pjj5l4szl7kq8u4h07se3675fsqcfh66vtks7hlckgz2kpaq0ssn309f`
2. `{ "withdraw_canceled_payment": { "amount": "[to_fill]"}}`
4. Contract 4 example:
1. `juno1ajs39qk0kd5xcjc8lvsym9q9g8q5jalzreum7nwqg036mqrw7utqf9gsu4`
2. `{ "withdraw_canceled_payment": { "amount": "[to_fill]"}}`
11. Wait for the unbonding time (4 weeks for the JUNO native coin)
12. Verify that you are the owner