> For the complete documentation index, see [llms.txt](https://dojo.lkmx.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dojo.lkmx.io/ingles/tezos/interact-with-a-smart-contract-with-taquito.md).

# Interact with a smart contract with Taquito

## Install Taquito

```bash
npm install @taquito/taquito
npm install @taquito/signer
```

### Import the library

```javascript
import { TezosToolkit } from '@taquito/taquito';
import { InMemorySigner} from '@taquito/signer';
```

Instantiate the library with the same contracts rpc

```javascript
const Tezos = new TezosToolkit('https://YOUR_PREFERRED_RPC_URL');
```

Maybe you have an error and need to install 'stream-browserify'.

```bash
npm install 'stream-browserify'
```

and add "stream" to vue.config.js file.

![](/files/2JNfL7qAWBGPfLXnt9Ol)

\ <br>

### Sign configuration

> You get your private key from your wallet, in settings.

```javascript
Tezos.setProvider({
  signer: new InMemorySigner('YOUR_PRIVATE_KEY'),
});
```

<br>

### Interact with the smart contract

> You need the contract address. Example: *KT1NvFHBQv3Zkv3wmWYqYpWWR8rMdd5pUG14* .

Send a method

```javascript
Tezos.contract
  .at('YOUR CONTRACT ADDRESS')
  .then((contract) => {
    return contract.methods.YOUR_METHOD(PARAMS).send();
  });
```

Get a op hash confimation

```javascript
Tezos.contract
  .at('YOUR CONTRACT ADDRESS')
  .then((contract) => {
    return contract.methods.YOUR_METHOD(PARAMS).send();
  })
  .then((op) => {
    console.log(`Waiting for ${op.hash} to be confirmed...`);
    return op.confirmation(1).then(() => op.hash);
  });
```

Catch error

```javascript
Tezos.contract
  .at('YOUR CONTRACT ADDRESS')
  .then((c) => {
    return c.methods.YOUR_METHOD(PARAMS).send();
  })
  .then((op) => {
    console.log(`Waiting for ${op.hash} to be confirmed...`);
    return op.confirmation(1).then(() => op.hash);
  })
  .then((hash) => console.log(`Operation injected: https://kathmandu.tzstats.com/${hash}`))
  .catch((error) => console.log(`Error: ${JSON.stringify(error, null, 2)}`));
```

Inspect the contract methods and data types

```javascript
Tezos.contract
  .at('YOUR CONTRACT ADDRESS')
  .then((c) => {
    let methods = c.parameterSchema.ExtractSignatures();
    console.log(JSON.stringify(methods, null, 2));
  })
  .catch((error) => console.log(`Error: ${error}`));
```

## Reference Links

* <https://opentezos.com/smart-contracts/simple-nft-contract-1/>
