# Interactuar con un Smart Contract con Taquito

## Instalar Taquito

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

### Importar la librería

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

Crear una instancia de la librería con los mismos contratos rpc:

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

Tal vez se encuentre un error y sea necesario instalar 'stream-browserify':

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

y agregar "stream" al archivo vue.config.js.

![](/files/2JNfL7qAWBGPfLXnt9Ol)

### &#x20;Sign configuration

> Obtener la clave privada de la billetera, en la configuración.

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

### Interact with the smart contract

> Es necesaria la dirección del contrato. Ejemplo: *KT1NvFHBQv3Zkv3wmWYqYpWWR8rMdd5pUG14* .

Enviar un method:

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

Obtener una confirmación de op hash:

```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)}`));
```

Inspeccionar los métodos de contrato y los tipos de datos:

```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}`));
```

## Enlaces de referencia

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


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://dojo.lkmx.io/tezos/interactuar-con-un-smart-contract-con-taquito.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
