-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update the Aragon SDK docs by commit 36647d5
- Loading branch information
Showing
115 changed files
with
9,065 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
--- | ||
title: Create a DAO | ||
--- | ||
|
||
## Create a DAO | ||
|
||
The `createDao` function allows you to create a DAO using the parameters you set for it. | ||
|
||
```ts | ||
import { | ||
Client, | ||
CreateDaoParams, | ||
DaoCreationSteps, | ||
DaoMetadata, | ||
TokenVotingClient, | ||
TokenVotingPluginInstall, | ||
VotingMode, | ||
} from "@aragon/sdk-client"; | ||
import { GasFeeEstimation } from "@aragon/sdk-client-common"; | ||
import { context } from "../index"; | ||
|
||
// Instantiate the general purpose client from the Aragon OSx SDK context. | ||
const client: Client = new Client(context); | ||
|
||
const metadata: DaoMetadata = { | ||
name: "My DAO", | ||
description: "This is a description", | ||
avatar: "image-url", | ||
links: [{ | ||
name: "Web site", | ||
url: "https://...", | ||
}], | ||
}; | ||
|
||
// Through pinning the metadata in IPFS, we can get the IPFS URI. You can read more about it here: https://docs.ipfs.tech/how-to/pin-files/ | ||
const metadataUri = await client.methods.pinMetadata(metadata); | ||
|
||
|
||
// You need at least one plugin in order to create a DAO. In this example, we'll use the TokenVoting plugin, but feel free to install whichever one best suites your needs. You can find resources on how to do this in the plugin sections. | ||
// These would be the plugin params if you need to mint a new token for the DAO to enable TokenVoting. | ||
const tokenVotingPluginInstallParams: TokenVotingPluginInstall = { | ||
votingSettings: { | ||
minDuration: 60 * 60 * 24 * 2, // seconds | ||
minParticipation: 0.25, // 25% | ||
supportThreshold: 0.5, // 50% | ||
minProposerVotingPower: BigInt("5000"), // default 0 | ||
votingMode: VotingMode.EARLY_EXECUTION, // default is STANDARD. other options: EARLY_EXECUTION, VOTE_REPLACEMENT | ||
}, | ||
newToken: { | ||
name: "Token", // the name of your token | ||
symbol: "TOK", // the symbol for your token. shouldn't be more than 5 letters | ||
decimals: 18, // the number of decimals your token uses | ||
minter: "0x...", // optional. if you don't define any, we'll use the standard OZ ERC20 contract. Otherwise, you can define your own token minter contract address. | ||
balances: [ | ||
{ // Defines the initial balances of the new token | ||
address: "0x2371238740123847102983471022", // address of the account to receive the newly minted tokens | ||
balance: BigInt(10), // amount of tokens that address should receive | ||
}, | ||
], | ||
}, | ||
}; | ||
|
||
// Creates a TokenVoting plugin client with the parameteres defined above (with an existing token). | ||
const tokenVotingInstallItem = TokenVotingClient.encoding | ||
.getPluginInstallItem(tokenVotingPluginInstallParams, "goerli"); | ||
|
||
const createDaoParams: CreateDaoParams = { | ||
metadataUri, | ||
ensSubdomain: "my-org", // my-org.dao.eth | ||
plugins: [tokenVotingInstallItem], // plugin array cannot be empty or the transaction will fail. you need at least one governance mechanism to create your DAO. | ||
}; | ||
|
||
// Estimate how much gas the transaction will cost. | ||
const estimatedGas: GasFeeEstimation = await client.estimation.createDao( | ||
createDaoParams, | ||
); | ||
console.log({ avg: estimatedGas.average, maximum: estimatedGas.max }); | ||
|
||
// Create the DAO. | ||
const steps = client.methods.createDao(createDaoParams); | ||
|
||
for await (const step of steps) { | ||
try { | ||
switch (step.key) { | ||
case DaoCreationSteps.CREATING: | ||
console.log({ txHash: step.txHash }); | ||
break; | ||
case DaoCreationSteps.DONE: | ||
console.log({ | ||
daoAddress: step.address, | ||
pluginAddresses: step.pluginAddresses, | ||
}); | ||
break; | ||
} | ||
} catch (err) { | ||
console.error(err); | ||
} | ||
} | ||
``` | ||
|
||
|
||
Returns: | ||
```tsx | ||
{ | ||
txHash: "0xb1c14a49...3e8620b0f5832d61c" | ||
} | ||
{ | ||
daoAddress: "0xb1c14a49...3e8620b0f5832d61c", | ||
pluginAddresses: ["0xb1c14a49...3e8620b0f5832d61c", "0xb1c14a49...3e8620b0f5832d61c"] | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
--- | ||
title: Deposit ETH | ||
--- | ||
|
||
## Deposit ETH to a DAO | ||
|
||
Handles the flow of depositing the native EVM token (when in mainnet, it's ETH) to an Aragon OSx DAO. | ||
|
||
```ts | ||
import { Client, DaoDepositSteps, DepositParams } from "@aragon/sdk-client"; | ||
import { GasFeeEstimation, TokenType } from "@aragon/sdk-client-common"; | ||
import { context } from "../index"; | ||
|
||
// Instantiate the general purpose client from the Aragon OSx SDK context. | ||
const client: Client = new Client(context); | ||
|
||
const depositParams: DepositParams = { | ||
daoAddressOrEns: "my-dao.dao.eth", | ||
amount: BigInt(10), // amount in wei | ||
type: TokenType.NATIVE, // "native" for ETH, otherwise "erc20" for ERC20 tokens | ||
}; | ||
|
||
// Estimate how much gas the transaction will cost. | ||
const estimatedGas: GasFeeEstimation = await client.estimation.deposit( | ||
depositParams, | ||
); | ||
console.log({ avg: estimatedGas.average, max: estimatedGas.max }); | ||
|
||
// Deposit ETH to the DAO. | ||
const steps = client.methods.deposit(depositParams); | ||
for await (const step of steps) { | ||
try { | ||
switch (step.key) { | ||
case DaoDepositSteps.DEPOSITING: | ||
console.log({ txHash: step.txHash }); | ||
break; | ||
case DaoDepositSteps.DONE: | ||
console.log({ amount: step.amount }); | ||
break; | ||
} | ||
} catch (err) { | ||
console.error(err); | ||
} | ||
} | ||
``` | ||
|
||
|
||
Returns: | ||
```tsx | ||
{ | ||
txHash: "0xb1c14a49...3e8620b0f5832d61c" | ||
} | ||
{ | ||
amount: 10n, | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
--- | ||
title: Deposit ERC-20 | ||
--- | ||
|
||
### Deposit ERC-20 Tokens to a DAO | ||
|
||
Deposits ERC-20 tokens to a DAO. | ||
|
||
- Similar to the ETH deposit flow | ||
- The `tokenAddress` field is required. This is the contract address of the ERC-20 token. | ||
- Will attempt to increase the ERC20 allowance if not sufficient. | ||
- More intermediate steps are yielded. | ||
|
||
```ts | ||
import { | ||
Client, | ||
DaoDepositSteps, | ||
DepositParams, | ||
SetAllowanceSteps, | ||
} from "@aragon/sdk-client"; | ||
import { GasFeeEstimation, TokenType } from "@aragon/sdk-client-common"; | ||
import { context } from "../index"; | ||
|
||
// Instantiate the general purpose client from the Aragon OSx SDK context. | ||
const client: Client = new Client(context); | ||
|
||
const depositParams: DepositParams = { | ||
daoAddressOrEns: "0x1234567890123456789012345678901234567890", // my-dao.dao.eth | ||
amount: BigInt(10), // amount in wei | ||
tokenAddress: "0x1234567890123456789012345678901234567890", // token contract adddress | ||
type: TokenType.ERC20, // "erc20" for ERC20 token, otherwise "native" for ETH | ||
}; | ||
|
||
// Estimate how much gas the transaction will cost. | ||
const estimatedGas: GasFeeEstimation = await client.estimation.deposit( | ||
depositParams, | ||
); | ||
console.log({ avg: estimatedGas.average, max: estimatedGas.max }); | ||
|
||
// Deposit the ERC20 tokens. | ||
const steps = client.methods.deposit(depositParams); | ||
for await (const step of steps) { | ||
try { | ||
switch (step.key) { | ||
case DaoDepositSteps.CHECKED_ALLOWANCE: | ||
console.log({ checkedAllowance: step.allowance }); | ||
break; | ||
case SetAllowanceSteps.SETTING_ALLOWANCE: | ||
console.log({ updateAllowanceTxHash: step.txHash }); | ||
break; | ||
case SetAllowanceSteps.ALLOWANCE_SET: | ||
console.log({ updatedAllowance: step.allowance }); | ||
break; | ||
case DaoDepositSteps.DEPOSITING: | ||
console.log({ depositingTxHash: step.txHash }); | ||
break; | ||
case DaoDepositSteps.DONE: | ||
console.log({ amount: step.amount }); | ||
break; | ||
} | ||
} catch (err) { | ||
console.error(err); | ||
} | ||
} | ||
``` | ||
|
||
|
||
Returns: | ||
```tsx | ||
{ | ||
checkedAllowance: 0n | ||
} | ||
{ | ||
updateAllowanceTxHash: "0xb1c14a49...3e8620b0f5832d61c" | ||
} | ||
{ | ||
updatedAllowance: 10n | ||
} | ||
{ | ||
depositingTxHash: "0xb1c14a49...3e8620b0f5832d61c" | ||
} | ||
{ | ||
amount: 10n | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
--- | ||
title: Deposit ERC-721 | ||
--- | ||
|
||
### Deposit ERC-721 Tokens to a DAO | ||
|
||
Deposits ERC-721 tokens to a DAO. | ||
|
||
- Similar to the ERC20 deposit flow | ||
- The `tokenAddress` field is required. This is the contract address of the ERC-721 token. | ||
- TokenId is required. This is the token ID of the ERC-721 token. | ||
- Calls the safeTransferFrom function of the ERC-721 token contract. | ||
|
||
```ts | ||
import { | ||
Client, | ||
DaoDepositSteps, | ||
DepositParams, | ||
SetAllowanceSteps, | ||
} from "@aragon/sdk-client"; | ||
import { GasFeeEstimation, TokenType } from "@aragon/sdk-client-common"; | ||
import { context } from "../index"; | ||
|
||
// Instantiate the general purpose client from the Aragon OSx SDK context. | ||
const client: Client = new Client(context); | ||
|
||
const depositParams: DepositParams = { | ||
daoAddressOrEns: "0x1234567890123456789012345678901234567890", // my-dao.dao.eth | ||
tokenAddress: "0x1234567890123456789012345678901234567890", // token contract adddress | ||
type: TokenType.ERC721, // "erc721" for ERC721 token | ||
tokenId: BigInt(1), // token ID of the ERC-721 token | ||
}; | ||
|
||
// Estimate how much gas the transaction will cost. | ||
const estimatedGas: GasFeeEstimation = await client.estimation.deposit( | ||
depositParams, | ||
); | ||
console.log({ avg: estimatedGas.average, max: estimatedGas.max }); | ||
|
||
// Deposit the ERC721 tokens. | ||
const steps = client.methods.deposit(depositParams); | ||
for await (const step of steps) { | ||
try { | ||
switch (step.key) { | ||
case DaoDepositSteps.DEPOSITING: | ||
console.log({ depositingTxHash: step.txHash }); | ||
break; | ||
case DaoDepositSteps.DONE: | ||
console.log({ tokenId: step.tokenId }); | ||
break; | ||
} | ||
} catch (err) { | ||
console.error(err); | ||
} | ||
} | ||
``` | ||
|
||
|
||
Returns: | ||
```tsx | ||
{ | ||
depositingTxHash: "0xb1c14a49...3e8620b0f5832d61c" | ||
} | ||
{ | ||
tokenId: 1n | ||
} | ||
``` | ||
|
||
```ts | ||
|
||
``` | ||
|
||
|
Oops, something went wrong.