Skip to content

Commit

Permalink
Merge pull request #146 from ChainSafe/v3-additional-sample
Browse files Browse the repository at this point in the history
Added the section for people to choose their wallet in the Getting Started
  • Loading branch information
kantagara authored Oct 14, 2024
2 parents 26a3afd + 5e5f244 commit 251fabf
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
4 changes: 3 additions & 1 deletion docs/v2.6/1_getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,6 @@ If you need to refer to the ChainSafe server settings area again, you can find i
### Drag and drop Web3Unity Prefab into your scene.
You can find the Web3Unity Prefab by typing Web3Unity in the project search bar. From the Search: Choose either 'All' or 'In Packages'

![](assets/getting-started/web3unity-prefab.png)
![](assets/getting-started/web3unity-prefab.png)

Now after you've done this, you need to choose your wallet provider. Check it out in the "Choose Your Wallet" section.
30 changes: 30 additions & 0 deletions docs/v2.6/9_sample-scripts-and-chain-interactions.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,36 @@ public class CustomContractSample : MonoBehaviour
}
```

## Creating Web3 instance just from the private key
If you want to start communicating with the blockchain by providing your private key, without using any wallet provider, you can do it the following:

```csharp
var web3Builder = new Web3Builder(Web3Unity.Web3.ProjectConfig, Web3Unity.Web3.ChainConfig).Configure(s =>
{
s.UseUnityEnvironment();
s.UseRpcProvider();
TempAccountProvider tempAccountProvider = new TempAccountProvider()
{
//Private key should be in the string format
Account = new Account("PRIV_KEY")
};

s.AddSingleton<IAccountProvider>(tempAccountProvider);
s.UseInProcessSigner();
s.UseInProcessTransactionExecutor();
});
var web3 = await web3Builder.LaunchAsync();

var account = web3.ServiceProvider.GetService<IAccountProvider>();
//We need to set the client of the transaction manager in order to send transactions properly.
account.Account.TransactionManager.Client = web3.ServiceProvider.GetService<IClient>();

public class TempAccountProvider : IAccountProvider
{
IAccount Account {get; set;}
}
```

## IPFS Upload
In order to upload your files to IPFS, you will need to obtain your storage API secret and bucket id from ChainSafe's storage [here](https://app.storage.chainsafe.io/).

Expand Down

0 comments on commit 251fabf

Please sign in to comment.