# smart-wallets-service-api

## GraphQL API Reference

GraphQl endpoints for smart-wallets!

**API Endpoints**

```
# devel:
https://smart-wallets.devel.original.works/graphql
# staging:
https://smart-wallets.stage.original.works/graphql
# prod:
https://smart-wallets.original.works/graphql
```

## Queries <a href="#group-operations-queries" id="group-operations-queries"></a>

### `getExecution`

**Description**

🔒 JWT Token

Returns execution by messageId.

**Response**

Returns a [`StartExecutionResDto!`](#definition-StartExecutionResDto)

**Arguments**

| Name                                          | Description |
| --------------------------------------------- | ----------- |
| `messageId` - [`String!`](#definition-String) |             |

**Example**

**Query**

```gql
query GetExecution($messageId: String!) {
  getExecution(messageId: $messageId) {
    id
    deployedSmartWalletId
    networkName
    transactionHash
    messageId
    userId
    createdAt
    updatedAt
  }
}
```

**Variables**

```json
{"messageId": "xyz789"}
```

**Response**

```json
{
  "data": {
    "getExecution": {
      "id": 987.65,
      "deployedSmartWalletId": 123.45,
      "networkName": "ropsten",
      "transactionHash": "abc123",
      "messageId": "xyz789",
      "userId": "xyz789",
      "createdAt": "2007-12-03T10:15:30Z",
      "updatedAt": "2007-12-03T10:15:30Z"
    }
  }
}
```

[Queries](#group-Operations-Queries)

### `getExecutions`

**Description**

🔒 JWT Token

Returns all operations on the chain for the given user.

**Response**

Returns a [`StartExecutionListResDto!`](#definition-StartExecutionListResDto)

**Example**

**Query**

```gql
query GetExecutions {
  getExecutions {
    list {
      id
      deployedSmartWalletId
      networkName
      transactionHash
      messageId
      userId
      createdAt
      updatedAt
    }
  }
}
```

**Response**

```json
{
  "data": {
    "getExecutions": {"list": [StartExecutionResDto]}
  }
}
```

[Queries](#group-Operations-Queries)

### `getOrCheckSmartWallet`

**Description**

🔒 JWT Token

Returns record of the smart wallet or false if does not exist.

**Response**

Returns a [`GetOrCheckSmartWalletDto!`](#definition-GetOrCheckSmartWalletDto)

**Example**

**Query**

```gql
query GetOrCheckSmartWallet {
  getOrCheckSmartWallet {
    smartWalletAddress
  }
}
```

**Response**

```json
{
  "data": {
    "getOrCheckSmartWallet": {
      "smartWalletAddress": "xyz789"
    }
  }
}
```

[Queries](#group-Operations-Queries)

### `getSmartWallet`

**Description**

🔒 JWT Token

Returns record of the smart wallet.

**Response**

Returns a [`SmartWalletDto!`](#definition-SmartWalletDto)

**Example**

**Query**

```gql
query GetSmartWallet {
  getSmartWallet {
    ownerUri
    walletAddress
    type
    deployedSmartWallets {
      id
      networkName
      smartWalletId
      messageId
      statusOnChain
      createdAt
      updatedAt
    }
    createdAt
    updatedAt
  }
}
```

**Response**

```json
{
  "data": {
    "getSmartWallet": {
      "ownerUri": "abc123",
      "walletAddress": "abc123",
      "type": "ENTERPRISE",
      "deployedSmartWallets": [DeployedSmartWalletDto],
      "createdAt": "2007-12-03T10:15:30Z",
      "updatedAt": "2007-12-03T10:15:30Z"
    }
  }
}
```

[Queries](#group-Operations-Queries)

### `getSmartWalletRecord`

**Description**

🔒 JWT Token

Returns record of the smart wallet.

**Response**

Returns a [`SmartWalletDto!`](#definition-SmartWalletDto)

**Arguments**

| Name                                         | Description          |
| -------------------------------------------- | -------------------- |
| `ownerUri` - [`String!`](#definition-String) | unique id for tenant |

**Example**

**Query**

```gql
query GetSmartWalletRecord($ownerUri: String!) {
  getSmartWalletRecord(ownerUri: $ownerUri) {
    ownerUri
    walletAddress
    type
    deployedSmartWallets {
      id
      networkName
      smartWalletId
      messageId
      statusOnChain
      createdAt
      updatedAt
    }
    createdAt
    updatedAt
  }
}
```

**Variables**

```json
{"ownerUri": "xyz789"}
```

**Response**

```json
{
  "data": {
    "getSmartWalletRecord": {
      "ownerUri": "abc123",
      "walletAddress": "xyz789",
      "type": "ENTERPRISE",
      "deployedSmartWallets": [DeployedSmartWalletDto],
      "createdAt": "2007-12-03T10:15:30Z",
      "updatedAt": "2007-12-03T10:15:30Z"
    }
  }
}
```

## Mutations <a href="#group-operations-mutations" id="group-operations-mutations"></a>

### `createSmartWallet`

**Description**

```
&#128274; <b><u>JWT Token</u></b>
                Creates a smart wallet and returns its data.                This is not a chain operation.                </code></pre>          </div>        </div>      </div>      <div class="doc-row">        <div class="doc-copy">          <div class="operation-response doc-copy-section">            <h5>Response</h5>            <p> Returns a <a href="#definition-SmartWalletDto"><code>SmartWalletDto!</code></a>            </p>          </div>          <div class="operation-arguments doc-copy-section">            <h5>Arguments</h5>            <table>              <thead>                <tr>                  <th>Name</th>                  <th>Description</th>                </tr>              </thead>              <tbody>                <tr>                  <td>                    <span class="property-name"><code>ownerUri</code></span> - <span class="property-type"><a href="#definition-String"><code>String!</code></a></span>                  </td>                  <td> unique id for tenant </td>                </tr>              </tbody>            </table>          </div>        </div>        <div class="doc-examples">          <h4 class="example-heading">Example</h4>          <div class="example-section example-section-is-code operation-query-example">            <h5>Query</h5>            <pre><code class="hljs language-gql"><span class="hljs-symbol"><span class="hljs-keyword">mutation</span> CreateSmartWallet<span class="hljs-tag">(<span class="hljs-code">$ownerUri</span>:<span class="hljs-type"> String!</span>)</span> <span class="hljs-tag">{
createSmartWallet(ownerUri: $ownerUri) {
ownerUri
walletAddress
type
deployedSmartWallets {
id
networkName
smartWalletId
messageId
statusOnChain
createdAt
updatedAt
}
createdAt
updatedAt
}
}
```

**Variables**

```json
{"ownerUri": "xyz789"}
```

**Response**

```json
{
"data": {
"createSmartWallet": {
"ownerUri": "abc123",
"walletAddress": "xyz789",
"type": "ENTERPRISE",
"deployedSmartWallets": [DeployedSmartWalletDto],
"createdAt": "2007-12-03T10:15:30Z",
"updatedAt": "2007-12-03T10:15:30Z"
}
}
}
```

[Mutations](#group-Operations-Mutations)

### `deploySmartWallet`

**Description**

🔒 JWT Token

```
    Deploy a smart wallet and returns its data.
This is a chain operation.
Use only for wallets with status transactionFailed
                </code></pre>          </div>        </div>      </div>      <div class="doc-row">        <div class="doc-copy">          <div class="operation-response doc-copy-section">            <h5>Response</h5>            <p> Returns a <a href="#definition-DeployedSmartWalletDto"><code>DeployedSmartWalletDto!</code></a>            </p>          </div>          <div class="operation-arguments doc-copy-section">            <h5>Arguments</h5>            <table>              <thead>                <tr>                  <th>Name</th>                  <th>Description</th>                </tr>              </thead>              <tbody>                <tr>                  <td>                    <span class="property-name"><code>networkName</code></span> - <span class="property-type"><a href="#definition-String"><code>String!</code></a></span>                  </td>                  <td> Name of the blockchain network </td>                </tr>                <tr>                  <td>                    <span class="property-name"><code>ownerUri</code></span> - <span class="property-type"><a href="#definition-String"><code>String!</code></a></span>                  </td>                  <td> unique id for tenant </td>                </tr>              </tbody>            </table>          </div>        </div>        <div class="doc-examples">          <h4 class="example-heading">Example</h4>          <div class="example-section example-section-is-code operation-query-example">            <h5>Query</h5>            <pre><code class="hljs language-gql"><span class="hljs-symbol"><span class="hljs-keyword">mutation</span> DeploySmartWallet<span class="hljs-tag">(
$networkName: String!,
$ownerUri: String!
) {
deploySmartWallet(
networkName: $networkName,
ownerUri: $ownerUri
) {
id
networkName
smartWalletId
messageId
statusOnChain
createdAt
updatedAt
}
}
```

**Variables**

```json
{
"networkName": "abc123",
"ownerUri": "xyz789"
}
```

**Response**

```json
{
"data": {
"deploySmartWallet": {
"id": 987.65,
"networkName": "ropsten",
"smartWalletId": 123.45,
"messageId": "xyz789",
"statusOnChain": "transaction_started",
"createdAt": "2007-12-03T10:15:30Z",
"updatedAt": "2007-12-03T10:15:30Z"
}
}
}
```

[Mutations](#group-Operations-Mutations)

### `startExecution`

**Description**

🔒 JWT Token

Starts transactions on the chain.

**Response**

Returns a [`String!`](#definition-String)

**Arguments**

| Name                                                                               | Description |
| ---------------------------------------------------------------------------------- | ----------- |
| `startExecutionArgs` - [`StartExecutionReqDto!`](#definition-StartExecutionReqDto) |             |

**Example**

**Query**

```gql
mutation StartExecution($startExecutionArgs: StartExecutionReqDto!) {
startExecution(startExecutionArgs: $startExecutionArgs)
}
```

**Variables**

```json
{"startExecutionArgs": StartExecutionReqDto}
```

**Response**

```json
{"data": {"startExecution": "xyz789"}}
```

## Types <a href="#group-types" id="group-types"></a>

### Boolean

**Description**

The `Boolean` scalar type represents `true` or `false`.

**Example**

```json
true
```

[Types](#group-Types)

### DateTime

**Description**

A date-time string at UTC, such as 2019-12-03T09:54:33Z, compliant with the date-time format.

**Example**

```gql
"2007-12-03T10:15:30Z"
```

[Types](#group-Types)

### DeployedSmartWalletDto

**Description**

Smart wallet object

**Fields**

| Field Name                                                                              | Description                                                |
| --------------------------------------------------------------------------------------- | ---------------------------------------------------------- |
| `id` - [`Float!`](#definition-Float)                                                    | Unique identifier for the object.                          |
| `networkName` - [`NetworkName!`](#definition-NetworkName)                               | Name of the blockchain network                             |
| `smartWalletId` - [`Float!`](#definition-Float)                                         | Unique identifier for the smart wallet object.             |
| `messageId` - [`String!`](#definition-String)                                           | A unique value. It is used to identify messages in events. |
| `statusOnChain` - [`DeployedSmartWalletStatus!`](#definition-DeployedSmartWalletStatus) | Name of the blockchain network                             |
| `createdAt` - [`DateTime!`](#definition-DateTime)                                       | Time at which the object was created.                      |
| `updatedAt` - [`DateTime!`](#definition-DateTime)                                       | Time at which the object was last updated.                 |

**Example**

```json
{
"id": 123.45,
"networkName": "ropsten",
"smartWalletId": 123.45,
"messageId": "xyz789",
"statusOnChain": "transaction_started",
"createdAt": "2007-12-03T10:15:30Z",
"updatedAt": "2007-12-03T10:15:30Z"
}
```

[Types](#group-Types)

### DeployedSmartWalletStatus

**Values**

| Enum Value               | Description |
| ------------------------ | ----------- |
| `transaction_started`    |             |
| `transaction_failed`     |             |
| `transaction_successful` |             |

**Example**

```gql
"transaction_started"
```

[Types](#group-Types)

### Float

**Description**

The `Float` scalar type represents signed double-precision fractional values as specified by [IEEE 754](https://en.wikipedia.org/wiki/IEEE_floating_point).

**Example**

```json
987.65
```

[Types](#group-Types)

### GetOrCheckSmartWalletDto

**Description**

smart wallet address

**Fields**

| Field Name                                            | Description |
| ----------------------------------------------------- | ----------- |
| `smartWalletAddress` - [`String`](#definition-String) |             |

**Example**

```json
{"smartWalletAddress": "abc123"}
```

[Types](#group-Types)

### NetworkName

**Values**

| Enum Value    | Description |
| ------------- | ----------- |
| `ropsten`     |             |
| `kovan`       |             |
| `ownet`       |             |
| `mainnet`     |             |
| `binance`     |             |
| `bnbtest`     |             |
| `sepolia`     |             |
| `local`       |             |
| `test`        |             |
| `polygon`     |             |
| `goerli`      |             |
| `mumbai`      |             |
| `ethereum`    |             |
| `shibuya`     |             |
| `amoy`        |             |
| `base`        |             |
| `baseSepolia` |             |

**Example**

```gql
"ropsten"
```

[Types](#group-Types)

### SmartWalletDto

**Description**

Smart wallet object

**Fields**

| Field Name                                                                                 | Description                                |
| ------------------------------------------------------------------------------------------ | ------------------------------------------ |
| `ownerUri` - [`String!`](#definition-String)                                               | Unique identifier for the enterprise.      |
| `walletAddress` - [`String!`](#definition-String)                                          | Ethereum wallet address.                   |
| `type` - [`SmartWalletType!`](#definition-SmartWalletType)                                 | Type of the smart wallet                   |
| `deployedSmartWallets` - [`[DeployedSmartWalletDto!]`](#definition-DeployedSmartWalletDto) |                                            |
| `createdAt` - [`DateTime!`](#definition-DateTime)                                          | Time at which the object was created.      |
| `updatedAt` - [`DateTime!`](#definition-DateTime)                                          | Time at which the object was last updated. |

**Example**

```json
{
"ownerUri": "xyz789",
"walletAddress": "abc123",
"type": "ENTERPRISE",
"deployedSmartWallets": [DeployedSmartWalletDto],
"createdAt": "2007-12-03T10:15:30Z",
"updatedAt": "2007-12-03T10:15:30Z"
}
```

[Types](#group-Types)

### SmartWalletType

**Values**

| Enum Value   | Description |
| ------------ | ----------- |
| `ENTERPRISE` |             |
| `RETAIL`     |             |

**Example**

```gql
"ENTERPRISE"
```

[Types](#group-Types)

### StartExecutionListResDto

**Description**

List of started executions on the chain for the given user

**Fields**

| Field Name                                                              | Description                                                |
| ----------------------------------------------------------------------- | ---------------------------------------------------------- |
| `list` - [`[StartExecutionResDto!]!`](#definition-StartExecutionResDto) | List of started executions on the chain for the given user |

**Example**

```json
{"list": [StartExecutionResDto]}
```

[Types](#group-Types)

### StartExecutionReqDto

**Description**

Argument required for trigger transaction on the chain

**Fields**

| Input Field                                   | Description                                                                        |
| --------------------------------------------- | ---------------------------------------------------------------------------------- |
| `to` - [`String!`](#definition-String)        | Receiver's Ethereum address                                                        |
| `value` - [`String!`](#definition-String)     | Ethereum coins amount                                                              |
| `chainId` - [`Float!`](#definition-Float)     | Unique identifier for the network.                                                 |
| `messageId` - [`String!`](#definition-String) | A unique value generated by the client. It is used to identify messages in events. |
| `data` - [`String!`](#definition-String)      | Encoded data of transaction to be executed.                                        |

**Example**

```json
{
"to": "abc123",
"value": "xyz789",
"chainId": 123.45,
"messageId": "xyz789",
"data": "xyz789"
}
```

[Types](#group-Types)

### StartExecutionResDto

**Description**

Object of initiated chain transaction.

**Fields**

| Field Name                                                | Description                                                                        |
| --------------------------------------------------------- | ---------------------------------------------------------------------------------- |
| `id` - [`Float!`](#definition-Float)                      | Unique identifier for the object.                                                  |
| `deployedSmartWalletId` - [`Float!`](#definition-Float)   | Unique identifier for the deployment of the smart wallet.                          |
| `networkName` - [`NetworkName!`](#definition-NetworkName) | Name of the blockchain network                                                     |
| `transactionHash` - [`String`](#definition-String)        | Hash of a transaction if execution has been submitted to the blockchain            |
| `messageId` - [`String!`](#definition-String)             | A unique value generated by the client. It is used to identify messages in events. |
| `userId` - [`String!`](#definition-String)                | Unique identifier for the user. The value comes from the auth0 token.              |
| `createdAt` - [`DateTime!`](#definition-DateTime)         | Time at which the object was created.                                              |
| `updatedAt` - [`DateTime!`](#definition-DateTime)         | Time at which the object was last updated.                                         |

**Example**

```json
{
"id": 123.45,
"deployedSmartWalletId": 987.65,
"networkName": "ropsten",
"transactionHash": "xyz789",
"messageId": "xyz789",
"userId": "xyz789",
"createdAt": "2007-12-03T10:15:30Z",
"updatedAt": "2007-12-03T10:15:30Z"
}
```

[Types](#group-Types)

### String

**Description**

The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

**Example**

```gql
"abc123"
```

[Documentation by Anvil SpectaQL](https://github.com/anvilco/spectaql)
