From 4eeb9f36e9fd1d65fb2aa03de05de7faf1f4d1fa Mon Sep 17 00:00:00 2001 From: Alexandru Popenta Date: Thu, 16 Nov 2023 16:43:56 +0200 Subject: [PATCH] mxpy guarded transactions --- docs/sdk-and-tools/sdk-py/mxpy-cli.md | 32 +++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/docs/sdk-and-tools/sdk-py/mxpy-cli.md b/docs/sdk-and-tools/sdk-py/mxpy-cli.md index 0295367a..02831e3d 100644 --- a/docs/sdk-and-tools/sdk-py/mxpy-cli.md +++ b/docs/sdk-and-tools/sdk-py/mxpy-cli.md @@ -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.