> For the complete documentation index, see [llms.txt](https://docs-priv.tria.so/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs-priv.tria.so/eip1193-provider-wip.md).

# EIP1193 - Provider (WIP)

### Initialization

A dApp can integrate the Tria SDK and construct the Tria provider to connect to any chain and perform transactions and contract calls.

```typescript
const provider = new TriaProvider({
    config,
    authUrl,
    dappDomain,
    dappLogo,
    aa,
    environment,
});
```

#### Params

* `config` (optional) -&#x20;
* `authUrl` (optional) -&#x20;
* `dappDomain` (optional) - The hostname/domain of the dApp. eg. `https://opensea.io`
* `dappLogo` (optional) - The logo of the dApp to be displayed in the wallet. eg. `https://your-dapp-logo.com`
* `environment` (optional - string) - The runtime environment. "testnet", "mainnet-staging", "mainnet"&#x20;
* `aa` (optional) - This is an object with the Account Abstraction params

  * `supportAa` (boolean) - If the dApp wants to enable Account Abstraction smart wallets
  * `pimlicoApiKey` (optional - string) - The dApp can pass their pimlico api key
  * `isSponsored` (optional - boolean) - Indicate whether the dApp wants to support sponsored transactions
  * `sponsorshipPolicyId` (optional - string) -&#x20;
  * `accountType` (optional - string) - The type of smart wallet to be created. Options - "Simple", "Kernel", "Safe", "Biconomy", "Etherspot"
  * `sponsorshipPolicyIds` (optional - string) -&#x20;

This `provider` can be used to perform any transactions or request for connected accounts, etc.

## Methods

The *request* should be a standard JSON-RPC payload, which should at a minimum specify the `method` and `params`

### Get Accounts

```typescript
const accounts = await provider.request({
    method: 'eth_accounts',
});
```

This will return the connected account in an array.

### Get Network and Chain ID

```typescript
const chainId = await provider.request({
    method: 'eth_chainId',
});

const networkId = await provider.request({
    method: 'net_version',
});
```

{% hint style="info" %}
Any request that requires user's consent/approval will trigger a wallet open.
{% endhint %}

### Send Transaction

```typescript
const result = await provider.request({
  method: 'eth_sendTransaction',
  params: [
    {
      from: accounts[0],
      to: recipientAddress,
      value,
      gasLimit: '0x5028',
      maxFeePerGas: '0x2540be400',
      maxPriorityFeePerGas: '0x3b9aca00',
    },
  ],
});
```

This method will open the wallet with all the provided wallet information. Once the user signs the transaction, it will be broadcasted and responds with a transaction hash.

### Sign Message

`eth_sign` and `personal_sign` opens up the wallet with the message.

#### eth\_sign

```typescript
const exampleMessage = 'Hello World';

const msg = `0x${Buffer.from(exampleMessage, 'utf8').toString('hex')}`;

const ethResult = await provider.request({
  method: 'eth_sign',
  params: [accounts[0], msg],
});
```

#### personal\_sign

```typescript
const exampleMessage = 'Hello World';

const msg = `0x${Buffer.from(exampleMessage, 'utf8').toString('hex')}`;

const sign = await provider.request({
    method: 'personal_sign',
    params: [msg, accounts[0]],
});
```
