# thirdweb SDK

thirdweb SDK es una biblioteca que permite a los desarrolladores construir aplicaciones web3 e interactuar con cualquier blockchain compatible con EMV.

Puede usar el SDK de thirdweb para construir aplicaciones e interactuar con contratos inteligentes desplegados en la red Base.

El SDK de thirdweb está disponible en varios lenguajes de programación, incluidos: [React,](https://portal.thirdweb.com/react) [React Native](https://portal.thirdweb.com/react-native), [TypeScript](https://portal.thirdweb.com/typescript), [Python](https://portal.thirdweb.com/python), [Go](https://portal.thirdweb.com/go) y [Unity.](https://portal.thirdweb.com/unity)

Visite la [documentación de thirdweb](https://portal.thirdweb.com/cli) para obtener más instrucciones sobre cómo usar los SDKs de thirdweb.

**Instalar**&#x20;

Para instalar el SDK de thirdweb, ejecute:

```graphql
graphqlCopy code
npm install @thirdweb-dev/sdk ethers@5

```

**Inicializando el SDK con Base**&#x20;

Para comenzar a usar el SDK, primero debe inicializar una instancia de ThirdWebSDK y conectarse a la red Base pasando la cadena Base.

Para inicializar el SDK con la red Base y obtener un contrato:

```jsx
javascriptCopy code
import { Base } from '@thirdweb-dev/chains';
import { ThirdwebSDK } from '@thirdweb-dev/sdk/evm';

const sdk = new ThirdwebSDK(Base);
const contract = await sdk.getContract('0x0000000000000000000000000000000000000000');

```

**INFO**

&#x20;El fragmento de código anterior utiliza el [SDK de React](https://portal.thirdweb.com/react). Los SDKs de thirdweb también están disponibles en [React Native](https://portal.thirdweb.com/react-native), [TypeScript](https://portal.thirdweb.com/typescript), [Python](https://portal.thirdweb.com/python), [Go](https://portal.thirdweb.com/go) y [Unity.](https://portal.thirdweb.com/unity)

Si, alternativamente, desea inicializar el SDK con Base Goerli (testnet), use el siguiente código:

```jsx
javascriptCopy code
import { BaseGoerli } from '@thirdweb-dev/chains';
import { ThirdwebSDK } from '@thirdweb-dev/sdk/evm';

const sdk = new ThirdwebSDK(BaseGoerli);
const contract = await sdk.getContract('0x0000000000000000000000000000000000000000');

```

**Interactuando con contratos inteligentes**&#x20;

Una vez que inicialice el SDK y se conecte a un contrato inteligente desplegado en Base, puede comenzar a llamar funciones en él usando el SDK.

**INFO**&#x20;

Cualquier interacción que realice con un contrato inteligente se realizará automáticamente desde la billetera conectada.

**Usando funciones de extensión de contrato**&#x20;

El SDK de thirdweb proporciona funciones de conveniencia cuando su contrato inteligente utiliza [extensiones](https://portal.thirdweb.com/contractkit/extensions). Esta es la forma más fácil de leer datos y escribir transacciones con sus contratos inteligentes.

Por ejemplo, si su contrato implementa la extensión [ERC721](https://portal.thirdweb.com/contractkit/erc721), puede utilizar todas las funciones del estándar [erc721 correspondiente en el SDK](https://portal.thirdweb.com/sdk/interacting-with-contracts/erc721).

A continuación, se muestra un fragmento de código que utiliza el gancho `useOwnedNFTs` para obtener una lista de NFTs propiedad de una única dirección de billetera:

```jsx
javascriptCopy code
import { useOwnedNFTs } from '@thirdweb-dev/react';

const { data, isLoading, error } = useOwnedNFTs(contract, '{{direccion_billetera}}');

```

**Uso**

```jsx
javascriptCopy code
import { useOwnedNFTs, useContract, useAddress } from '@thirdweb-dev/react';

// La dirección de su contrato inteligente
const contractAddress = '{{direccion_contrato}}';

function App() {
  const address = useAddress();
  const { contract } = useContract(contractAddress);
  const { data, isLoading, error } = useOwnedNFTs(contract, address);
}

```

Para obtener más ejemplos sobre cómo usar funciones de extensión de contrato, visite la [documentación para desarrolladores de thirdweb.](https://portal.thirdweb.com/sdk/interacting-with-contracts#using-contract-extensions)

**Leyendo datos del contrato**&#x20;

Si su contrato no utiliza ninguna [extensión](https://portal.thirdweb.com/contractkit/extensions), o desea llamar directamente a funciones en su contrato inteligente para leer datos, puede usar el gancho `useContractRead.`

Lea datos en su contrato desde una billetera conectada:

```jsx
javascriptCopy code
const { contract } = useContract('{{direccion_contrato}}');
const { data: myData, isLoading } = useContractRead(contract, 'miFuncion');

```

**Escribiendo transacciones**&#x20;

Si su contrato no utiliza ninguna [extensión](https://portal.thirdweb.com/contractkit/extensions), o desea llamar directamente a funciones en su contrato inteligente para escribir datos, puede usar el gancho `useContractWrite.`

Realice transacciones en su contrato desde una billetera conectada:

<figure><img src="https://1481051992-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZuu5GAvqRanjAgcsL89r%2Fuploads%2F2ucvfV7DIyDlmGA16WKq%2Fimage.png?alt=media&#x26;token=efbe66ae-ad98-466e-9284-993159ad6b1e" alt=""><figcaption></figcaption></figure>


---

# 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://base-es.gitbook.io/base/overview/clientes/thirdweb-sdk.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.
