> For the complete documentation index, see [llms.txt](https://yuga.gitbook.io/zkyuga-whitepaper/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://yuga.gitbook.io/zkyuga-whitepaper/developer-guide/interacting-with-contracts-using-zkyugaclient.md).

# Interacting with Contracts using ZkyugaClient

## Interacting with Contracts using `ZkyugaClient`

The `zkyugaClient` simplifies interaction with various Ethereum smart contracts. It includes methods like `getERC20Instance` and `getERC721Instance`, which facilitate the instantiation of ERC-20 and ERC-721 token contracts. These instances enable developers to interact more conveniently with the respective token standards.

***

### `getERC20Instance` Method

#### Description

This method helps you connect with ERC-20 token contracts. Imagine you have a digital token (like a loyalty point) and want to check your balance or transfer tokens. This method provides an object (ERC20Instance) that allows you to perform such actions.

#### Method Signature

```javascript
getERC20Instance(contractAddress: string): ERC20Instance
```

#### Parameters

What you need: Just provide the contract address of the ERC-20 token you want to interact with.

| Parameter       | Type   | Description                                                                  |
| --------------- | ------ | ---------------------------------------------------------------------------- |
| contractAddress | string | The Ethereum address of the ERC-20 token contract you wish to interact with. |

#### Returns

* An `ERC20Instance` object that encapsulates the functionalities of the ERC-20 token located at the specified contract address.

#### Usage Example

```javascript
const erc20Address = "0x3f36f83b0d43EE58FAE33D58A182a14aB9aE5876";
const erc20 = zkyugaClient.getERC20Instance(erc20Address);
```

***

### `getERC721Instance`

#### Description

This method allows developers to obtain an instance of an ERC-721 token contract, thereby offering a straightforward way to interact with the unique functionalities of non-fungible tokens (NFTs).

#### Method Signature

```javascript
getERC721Instance(contractAddress: string): ERC721Instance
```

#### Parameters

**What you need:** Provide the contract address of the ERC-721 contract you want to connect to.

| Parameter       | Type   | Description                                                                  |
| --------------- | ------ | ---------------------------------------------------------------------------- |
| contractAddress | string | The Ethereum address of the ERC-721 token contract you aim to interact with. |

#### Returns

* An `ERC20Instance` represents an entity that encompasses the features and operations of the ERC-20 token found at the provided contract address.

#### Usage Example

```javascript
const erc721Address = "0x3f36f83b0d43EE58FAE33D58A182a14aB9aE5876";
const erc721 = zkyugaClient.getERC721Instance(erc721Address);
```

***

### `getStableCoinInstance` (New!):

#### Description

This method allows you to connect with Stablecoin contracts, which are cryptocurrencies pegged to real-world assets like the US dollar.

#### Method Signature

```javascript
getStableCoinInstance(address: string, rpc: string, provider?: any): StableCoin
```

#### Parameters

**What you need**: Provide the contract address of the Stablecoin and the network's RPC URL (like an access point). You can also optionally specify a custom provider for web3 interactions.

* `address`: string - The address of the StableCoin contract.
* `rpc`: string (optional, default = "<https://zkyuga.network/rpc>") - The RPC URL of the blockchain network.
* `provider`: any (optional) - A custom provider for web3 interactions.

#### Return

* Returns a new instance of `StableCoin` configured with the specified address and RPC.

#### Usage Example

```javascript
const stableCoinInstance = getStableCoinInstance("0x123...", "https://mainnet.zkyuga.network/rpc");
```

***

### Important Points:

* Double-check the contract addresses you provide. Mistakes can lead to errors.
* Once you have the instance (`ERC20Instance` or `ERC721Instance`), you can use various methods specific to each token standard.
* Refer to the official documentation and contract details for in-depth information on available functionalities and methods.

***
