Skip to content

Commit

Permalink
mxpy guarded transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
popenta committed Nov 16, 2023
1 parent 53a7f03 commit 4eeb9f3
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions docs/sdk-and-tools/sdk-py/mxpy-cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,38 @@ In case you want to save the transaction you can also provide the `--outfile` ar

[comment]: # (mx-context-auto)

## Guarded transactions

If your address is guarded, you'll have to provide some additional arguments because your transaction needs to be co-signed.

The first extra argument we'll need is the `--guardian` argument. This specifies the guardian address of our address. Then, if our account is guarded by a service like our trusted co-signer service we have to provide the `--guardian-service-url` which specifies where the transaction is sent to be co-signed.

Keep in mind that **mxpy** always calls the `/sign-transaction` endpoint of the `--guardian-service-url` you have provided. Another argment we'll need is `--guardian-2fa-code` which is the code generated by an external authenticator.

Each guarded transaction needs an additional `50000` gas for the `gasLimit`. The `version` field needs to be set to `2`. The `optons` field needs to have the second least signinficant bit set to "1".

:::note
Here are the urls to our hosted co-signer services:
- Mainnet: https://tools.multiversx.com/guardian
- Devnet: https://devnet-tools.multiversx.com/guardian
- Testnet: https://testnet-tools.multiversx.com/guardian
:::

```sh
mxpy tx new --pem ~/multiversx-sdk/testwallets/latest/users/alice.pem --recall-nonce \
--receiver erd1spyavw0956vq68xj8y4tenjpq2wd5a9p2c6j8gsz7ztyrnpxrruqzu66jx \
--gas-limit 200000 --value 1000000000000000000 \
--proxy https://devnet-gateway.multiversx.com --chain D \
--guardian erd1k2s324ww2g0yj38qn2ch2jwctdy8mnfxep94q9arncc6xecg3xaq6mjse8 \
--guardian-service-url https://devnet-tools.multiversx.com/guardian \
--guardian-2fa-code 123456 --version 2 --options 2
--send
```

If your address is guarded by another wallet, you'll still need to provide the `--guardian` argument and the guardian's wallet that will co-sign the transaction, but you don't need to provide the 2fa code and the service url. You can provide the guardian's wallet using one of the following arguments: `--guardian-pem`, `--guardian-keyfile`, or `--guardian-ledger`.

[comment]: # (mx-context-auto)

## Using the Ledger hardware wallet

You can sign any transaction (regular transfers, smart contract deployments and calls) using a Ledger hardware wallet by leveraging the `--ledger` command-line argument.
Expand Down

0 comments on commit 4eeb9f3

Please sign in to comment.