Skip to content
This repository has been archived by the owner on Jan 5, 2024. It is now read-only.

Commit

Permalink
Merge branch 'main' into storage-docs
Browse files Browse the repository at this point in the history
  • Loading branch information
saminacodes authored Sep 8, 2023
2 parents 4f849dd + ba97724 commit 84e5166
Show file tree
Hide file tree
Showing 17 changed files with 175 additions and 43 deletions.
2 changes: 1 addition & 1 deletion docs/go/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ go get github.com/thirdweb-dev/go-sdk/v2/thirdweb

## Getting Started

To start using this SDK, you just need to pass in a provider configuration. It's also strongly recommended that you use your thirdweb API keys with the SDK in order to get the best infrastructure performance (across RPCs, IPFS, etc.) - you can learn more about creating and using API keys [here](https://portal.thirdweb.com/api-keys).
To start using this SDK, you just need to pass in a provider configuration. It's also recommended that you use your thirdweb API keys with the SDK in order to get the best infrastructure performance (across RPCs, IPFS, etc.) - you can learn more about creating and using API keys [here](https://portal.thirdweb.com/api-keys).

### Instantiating the SDK

Expand Down
17 changes: 0 additions & 17 deletions docs/onboarding/0 1 Platform Overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,6 @@ import ThemedImage from "@theme/ThemedImage";
thirdweb is a comprehensive development framework that empowers you to seamlessly
build, launch, and manage web3 applications and games across any EVM-compatible blockchain.

:::info API Keys
The following thirdweb products and services now require an API key:
- [**Smart Wallet**](/glossary/smart-wallet)
- [**Storage**](/storage)
- The following [**CLI**](/cli) commands (these commands require you to login using the [login](/cli/commands/login) command):
- [**Generate**](/cli/commands/generate)
- [**Deploy**](/cli/commands/deploy)
- [**Publish**](/cli/commands/publish)
- [**Upload**](/cli/commands/upload)
- **RPCs**

Visit the thirdweb [**Dashboard**](https://thirdweb.com/create-api-key) to create an API key.

To learn more about API keys, please visit the [**API Keys**](/api-keys) **page**.
:::


## Architecture

Whether you're developing decentralized applications from scratch or enhancing existing ones,
Expand Down
1 change: 1 addition & 0 deletions docs/onboarding/11 Storage/0 Overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ You can easily upload and pin individual files or entire directories to IPFS usi

Storage supports all types of files, including images, 3D models, videos, audio, full applications, and more.


### Features

- **Save Development Time:** Storage manages the difficult aspects of managing decentralized files, such as handling, pinning, and uploading metadata formats.
Expand Down
2 changes: 1 addition & 1 deletion docs/python/getting-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ To get started, install the thirdweb package into your Python project:
pip install thirdweb-sdk
```

:::info
:::info API Key
You will require an API key to use thirdweb’s infrastructure services with the SDK. If you haven’t created a key yet you can do so for free from the [**thirdweb dashboard**](https://thirdweb.com/create-api-key).
:::

Expand Down
8 changes: 4 additions & 4 deletions docs/react-native/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ displayed_sidebar: react-native

# Getting Started

:::info
You will require an API key to use thirdweb’s infrastructure services with the SDK. If you haven’t created a key yet you can do so for free from the [**thirdweb dashboard**](https://thirdweb.com/create-api-key).
:::

Our SDK uses a [Provider Pattern](https://flexiple.com/react/provider-pattern-with-react-context-api/); meaning any component within the `ThirdwebProvider` will have access to the SDK.

Let's take a look at a typical setup:

## API Key

You will require an API key to use thirdweb’s infrastructure services with the SDK. If you haven’t created a key yet you can do so for free from the [**thirdweb dashboard**](https://thirdweb.com/create-api-key).

## Configure the `ThirdwebProvider`

Specify the network your smart contracts are deployed to in the `activeChain` prop and wrap your application like so:
Expand Down
5 changes: 2 additions & 3 deletions docs/react-native/storage.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ Get the instance of the `ThirdwebStorage` class being used by the [`ThirdwebProv

Allows you to use the TypeScript SDK functionality of [Storage](/storage) in your React native app.

:::caution API Key
## API Key

You will require an API key to use thirdweb’s storage services with the SDK. If you haven’t created a key yet you can do so for free from the [**thirdweb dashboard**](https://thirdweb.com/create-api-key).

You can then obtain a `clientId` from the API key which you will need to pass to the [`ThirdwebProvider`](/react/react.thirdwebprovider) component:
Expand All @@ -29,8 +30,6 @@ const App = () => {

Please note that you will also need to get your app's `bundleId` and pass it in the `Allowed Bundle IDs` section when creating your API key. Check [how you can get your app's `bundleId`](https://portal.thirdweb.com/api-keys#react-native).

:::

## useStorage hook

Configurable in the [`storageInterface`](/react/react.thirdwebprovider#storageinterface-optional) prop of the [`ThirdwebProvider`](/react/react.thirdwebprovider).
Expand Down
4 changes: 2 additions & 2 deletions docs/react/ThirdwebProvider.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ Wrap your app in the `ThirdwebProvider` to access the SDK’s functionality

## Usage

:::caution API Keys
To use the React SDK, you need to first obtain an API key from the [Dashboard](https://thirdweb.com/dashboard) and then copy the `clientId` to pass as a prop to the `ThirdwebPovider`.
:::info API Keys
You will require an API key to use thirdweb's infrastructure services with the SDK, you need to first obtain an API key from the [dashboard](https://thirdweb.com/dashboard) and then copy the `clientId` to pass as a prop to the `ThirdwebPovider`.
:::

If you are using one of our <a href="#default-chains">default chains</a>, provide the name of the chain as a `string` to the `activeChain` prop.
Expand Down
2 changes: 1 addition & 1 deletion docs/react/getting-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ export default function Home() {

<br />

:::caution API KEYS
:::info API Key
You will require an API key to use thirdweb's infrastructure services with the SDK. If you haven't created a key yet you can do so for **free** from the [**thirdweb dashboard**](https://thirdweb.com/create-api-key).
:::

Expand Down
5 changes: 2 additions & 3 deletions docs/react/storage/usestorage.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ Get the instance of the `ThirdwebStorage` class being used by the [`ThirdwebProv

Allows you to use the TypeScript SDK functionality of [Storage](/storage) in your React app.

:::caution API Key
## API Key

You will require an API key to use thirdweb’s storage services with the SDK. If you haven’t created a key yet you can do so for free from the [**thirdweb dashboard**](https://thirdweb.com/create-api-key).

You can then obtain a `clientId` from the API key which you will need to pass to the [`ThirdwebProvider`](/react/react.thirdwebprovider) component:
Expand All @@ -25,8 +26,6 @@ const App = () => {
};
```

:::

Configurable in the [`storageInterface`](/react/react.thirdwebprovider#storageinterface-optional) prop of the [`ThirdwebProvider`](/react/react.thirdwebprovider).

The hook returns a [`ThirdwebStorage`](/typescript/storage) instance. View the [TypeScript Storage](/typescript/storage) documentation for more information.
Expand Down
5 changes: 2 additions & 3 deletions docs/react/storage/usestorageupload.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ Hook for uploading files to IPFS and retrieving the IPFS URI.
import { useStorage } from "@thirdweb-dev/react";
```

:::caution API Key
## API key

You will require an API key to use thirdweb’s storage services with the SDK. If you haven’t created a key yet you can do so for free from the [**thirdweb dashboard**](https://thirdweb.com/create-api-key).

You can then obtain a `clientId` from the API key which you will need to pass to the [`ThirdwebProvider`](/react/react.thirdwebprovider) component:
Expand All @@ -27,8 +28,6 @@ const App = () => {
};
```

:::

## Usage

```jsx
Expand Down
2 changes: 1 addition & 1 deletion docs/typescript/getting-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ npx thirdweb create app

<br />

:::info
:::info API Key
You will require an API key to use thirdweb’s infrastructure services with the SDK. If you haven’t created a key yet you can do so for free from the [**thirdweb dashboard**](https://thirdweb.com/create-api-key).
:::

Expand Down
2 changes: 1 addition & 1 deletion docs/unity/getting-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import GettingStartedLiveEditor from "@components/live-code/snippets/GettingStar
Before getting started, you'll need to
[download and install the Unity Hub and Unity Editor](https://learn.unity.com/tutorial/install-the-unity-hub-and-editor).

:::info
:::info API Key
You will require an API key to use thirdweb’s infrastructure services with the SDK. If you haven’t created a key yet you can do so for free from the [**thirdweb dashboard**](https://thirdweb.com/create-api-key).
:::

Expand Down
148 changes: 148 additions & 0 deletions docs/unity/interacting-with-contracts/prepare.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
---
title: Transaction Builder
slug: /contract.prepare
hide_title: true
---

# Transaction Builder

By default, all transactions initiated using the SDK perform every step of the process for a transaction; From preparing and building the transaction all the way to waiting until it has been mined, and the data is available to be read from the blockchain.

To gain more granular control over the transaction process, all Contract objects come with a Prepare function that returns a Transaction object, which can be used to build, fine-tune, and execute the transaction.

## Usage

```csharp
string connectedAddress = await ThirdwebManager.Instance.SDK.wallet.GetAddress();
Transaction transaction = await contract.Prepare(
functionName: "claim",
from: connectedAddress, // optional, defaults to connected address
args: new object[] { connectedAddress, 0, 1 }
);
// transaction.SetValue("0.00000000001");
// transaction.SetGasLimit("100000");
try
{
var data = await transaction.Simulate();
Debugger.Instance.Log("[Custom Call] Simulate Successful", "Data: " + data.ToString()");
}
catch (System.Exception e)
{
Debugger.Instance.Log("[Custom Call] Simulate Error", e.Message);
return;
}

await transaction.EstimateAndSetGasLimitAsync();

var gasPrice = await transaction.GetGasPrice();
Debug.Log($"Gas Price: {gasPrice}");

var gasCosts = await transaction.EstimateGasCosts();
Debug.Log($"Gas Cost: {gasCosts.wei} WEI");

Debugger.Instance.Log("[Custom Call] Transaction Preview", transaction.ToString());

try
{
string transactionResult = await transaction.Send(gasless: false);
Debugger.Instance.Log("[Custom Call] Send Successful", "Tx Hash: " + transactionResult);
}
catch (System.Exception e)
{
Debugger.Instance.Log("[Custom Call] Send Error", e.ToString());
}
}
```

## EstimateGasCost

Estimate the gas cost for a transaction.

```csharp
var gasCost = await tx.EstimateGasCosts();
```

<details>
<summary>Configuration</summary>
<div>

### Return Value

Returns the gas cost for this transaction in both `ether` and `wei`.

```csharp
GasCosts;
```

</div>
</details>

## EstimateGasLimit

Estimate the gas limit for a transaction.

```csharp
var gasLimit = await tx.EstimateGasLimit();
```

<details>
<summary>Configuration</summary>
<div>

### Return Value

Returns the gas limit for this transaction.

```csharp
BigInteger;
```

</div>
</details>

## Send

Send the transaction without waiting for it to be mined. This is useful for when you want the transaction to be executed, but don’t need the data returned.

```csharp
string txHash = await tx.Send();
```

<details>
<summary>Configuration</summary>
<div>

### Return Value

Returns the transaction hash as a `string`.

```csharp
string;
```

</div>
</details>

## Execute

Send the transaction and wait for it to be mined. This is useful for when you want the transaction to be executed, and need the data returned.

```csharp
TransactionResult result = await tx.SendAndWaitForTransactionResult();
```

<details>
<summary>Configuration</summary>
<div>

### Return Value

Returns the transaction result as a <see cref="TransactionResult"/> object.

```csharp
TransactionResult;
```

</div>
</details>
5 changes: 5 additions & 0 deletions sidebars/unity.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ const sidebars = {
label: "Initiate Contract Transactions",
id: "interacting-with-contracts/write",
},
{
type: "doc",
label: "Transaction Builder",
id: "interacting-with-contracts/prepare",
},
{
type: "category",
label: "Using Extensions",
Expand Down
6 changes: 2 additions & 4 deletions src/theme/DocSidebarItem/Link/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const iconMapping = {
"UI Components": "/assets/product/ui.png",
Home: "/assets/icons/home.png",
"Overview ": "/assets/icons/wrench.png",
"API Keys": "/assets/icons/rocket.png",
"API Keys": "/assets/resources/key.png",
Templates: "/assets/resources/sdk-reference.svg",
Guides: "/assets/resources/guides.svg",
CLI: "/assets/product/CLI.png",
Expand Down Expand Up @@ -110,9 +110,7 @@ export default function DocSidebarItemLink({
}
${
(label === "Home" ||
label === "Overview " ||
label === "API Keys") &&
(label === "Home" || label === "Overview ") &&
styles.invertLightIcon
}
Expand Down
4 changes: 2 additions & 2 deletions src/theme/DocSidebarItems/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function DocSidebarItems({ items, ...props }) {
const sidebarItems = [
{
title: null, // No title for the first section
items: ["Home", "Overview ", "API Keys"],
items: ["Home", "Overview "],
},
{
title: "Wallets",
Expand Down Expand Up @@ -77,7 +77,7 @@ function DocSidebarItems({ items, ...props }) {
},
{
title: "Resources",
items: ["Templates", "Guides", "Glossary"],
items: ["API Keys", "Templates", "Guides", "Glossary"],
},
];

Expand Down
Binary file added static/assets/resources/key.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 84e5166

Please sign in to comment.