{
  "type": "script",
  "title": "Multi Stake Withdrawal",
  "description": "Script that requests 3 child wallet's reward addresses from an specific workspace, to later withdraw some staking rewards from each of them on a single transaction. You need to have staking rewards on each child wallet and run 'Multi Stake Delegation' demo first or load its wallet configuration on this device",
  "require": {
    "not": {
      "walletTypeIn": [
        "extension"
      ]
    }
  },
  "exportAs": "MultiWithdrawlDemo",
  "run": {
    "setWorkspace": {
      "type": "setCurrentWorkspace",
      "workspaceId": "demos"
    },
    "dependencies": {
      "type": "script",
      "run": {
        "rewardValue": {
          "type": "data",
          "value": "1000000"
        },
        "addresses": {
          "type": "getAddresses",
          "keyPattern": "{artifactName}"
        }
      }
    },
    "txs": {
      "type": "script",
      "run": {
        "buildWithdraw": {
          "type": "buildTx",
          "name": "WithdrawTx",
          "tx": {
            "withdrawals": {
              "A": {
                "address": "{get('cache.dependencies.addresses.RewardAddress-A.address')}",
                "quantity": "{get('cache.dependencies.rewardValue')}"
              },
              "B": {
                "address": "{get('cache.dependencies.addresses.RewardAddress-B.address')}",
                "quantity": "{get('cache.dependencies.rewardValue')}"
              },
              "C": {
                "address": "{get('cache.dependencies.addresses.RewardAddress-C.address')}",
                "quantity": "{get('cache.dependencies.rewardValue')}"
              }
            }
          }
        },
        "signWithdraw": {
          "type": "signTxs",
          "namePattern": "signed-{key}",
          "detailedPermissions": false,
          "txs": {
            "withdraw": "{get('cache.txs.buildWithdraw.txHex')}"
          }
        },
        "submitWithdraw": {
          "type": "submitTxs",
          "namePattern": "submitted-{key}",
          "txs": "{get('cache.txs.signWithdraw')}"
        }
      }
    },
    "finally": {
      "type": "script",
      "exportAs": "MultiWithdraw",
      "run": {
        "signWithdraw": {
          "type": "macro",
          "run": "{get('cache.txs.buildWithdraw.txHash')}"
        }
      }
    }
  }
}