---
# System prepended metadata

title: Autonomy Login
tags: [Feral File, Autonomy, MVA]

---

# Autonomy Login

###### tags: `Autonomy` `Feral File` `MVA`

To utilize Autonomy app to manage multiple accounts(ethereum, tezos) and use with Feral File, we need to build our own walletconnect, say Autonomy connect, to facilitate the connect and signing process between blockchains.

## Autonomy account management

This is a derivation path of autonomy app

- 44/0/0/DID
- 44/0/0/tezos
- 44/0/0/eth

## Connect

This is the connect process 

### Sequential Diagram

```mermaid
sequenceDiagram
autonumber

Client->>+Feral File: Connect 
Feral File->>+Connect Server: Establish session connection
Connect Server-->>-Feral File: session ID
Feral File-->>-Client: QR Code
Client->>+Autonomy App: Scan QR code
Autonomy App->>+Connect Server: Establish session connection<br>use session ID
Connect Server-->>-Autonomy App: Establish session connection
Autonomy App-->>-Feral File: Sign connect message using DID
Feral File->>Feral File: Register / Login
Feral File-->>Client: Logged in <br> (session optional, for download?)
```

### Payload

1. Connect message

```json
{
    "did": 
    "ethereumAddress": 
    "tezosAddress": 
    "timestamp": 
    "signature": did_sign(eth|tezos|timestamp)
    "eth_signature": eth_sign(did|timestamp)
    "tezos_signature": tezos_sign(did|timestamp)
}
```

## Sign

This is the signing process 

### Sequential Diagram

```mermaid
sequenceDiagram
autonumber

Client->>Feral File: Actions 
Feral File->>+Autonomy App: Prepare action information <br> and send to autonomy app
Autonomy App->>-Autonomy App: Pop-up confirmation
Client->>Autonomy App: confirm
Autonomy App->>+Autonomy App: Finish the action<br>(sign / broadcast)
Autonomy App-->>-Feral File: Done
```

### Payload 

```json
{
    "did": 
    "account": <eth or tez address>
    "action": <sign message / sign transaction> (TBD)
    "data": (optional, TBD)
    "timestamp":
    "signature": did_sign(account|action|data|timestamp)
}
```

# Wallet Connect 2.0 Protocols:

### Chain name: `autonomy`
### Chain id:
    - Mainnet: 0
    - Testnet: 1
### Methods:

** Note update `eth` -> `eip155:1`

- `Approval`
    - Request
    ```json
    {
        "autonomy": {
          "methods": [
            "au_permissions",
            "au_sign",
            "au_sendTransaction",
          ],
          "chains": [
            "autonomy:<chain ID>",
          ],
          "events": [],
        }
    }
    ```
    - Response: json string
    ```json
    {
        "autonomy": {
            "accounts": ["<did:key:>"],
        }
    }
    ```

- `au_permissions`

    - Request
    ```json
        {
            "account": "did:key:..",
            "message": "...'$OWN_ADDRESS$'...",
            "permissions": [
                {
                    "type": "chains_request",
                    "includeLinkedAccount": true,
                    "request": {
                        "chains": ["eip155:1", "tezos"]
                    }
                }
            ]
        }
    ```
    
    - Response: json string
    ```json
        {
            "signature": "did_signature",
            "permissionResults": [
                {
                    "type": "chains_request"
                    "result": {
                        "chains": [
                            {
                                "chain": "eip155:1",
                                "address": "0x...",
                                /*"signature": "eth_signauture"*/
                            },
                            {
                                "chain": "tezos",
                                "address": "tz1...",
                                "publicKey": "edpk..",
                                /*"signature": "tezos_signauture"*/
                            }
                        ]
                    }
                }
            ]
        }
    ```
    
- `au_sign`

    - Request
    ```json
        {
            "chain": "eip155:1|tezos|autonomy",
            "adress": "eth_address|tezos_address|did:key",
            "message": ""
        }
   ```
    
    - Response
    ```
    signature
    ```
- `au_sendTransaction`

    - Request
    ```json
        {
            "chain": "tezos",
            "address": "",
            "transactions": [Transactdion]
        }
    ```
    
    - Response
    ```
    transaction_hash
    ```

### Transaction Data
#### Ethereum transaction
```json=
{
  "from": "",
  "to": "",
  "nonce": "<optional>",
  "gasPrice": "<optional>",
  "gas": "<optional>",
  "gasLimit": "<optional>",
  "value": "<optional>",
  "data": ""
}
```
#### Tezos transaction (operation)
https://opentezos.com/tezos-basics/operations
- Origination
```json=
{
  "kind": "origination",
  "balance": 123,
  "code": [
    {}
  ],
  "storage": {},
  "fee": "<optional>",
  "gasLimit": "<optional>",
  "storageLimit": "<optional>"
}
```
- Transaction
```json=
{
  "kind": "transaction",
  "amount": "",
  "destination": "",
  "fee": "<optional>",
  "gasLimit": "<optional>",
  "storageLimit": "<optional>",
  "entrypoint": "<optional>",
  "parameters": {}
}
```

***\****Note: Backup case: alternative if cannot combine eth & tezos transactions***
- `eth_sendTransaction`
- `tezos_sendTransaction`

    
