useNewDao MUTATION
Lower-level hook for creating a new DAO. It requires that you have already generated the encoded data for the plugins you want to install in the DAO. If you want to create a DAO with one of the official plugins, you can use the hook for that specific plugin instead.
import { useNewDao } from '@daobox/use-aragon'
Usage
import { useNewDao } from '@daobox/use-aragon'
function App() {
const installData: IPluginInstallItem = useGenerateInstallData({
pluginAddress: '0xPluginAddress',
pluginInitParams: { ... },
})
const { mutate, creationStatus, daoAddress, daoTxHash } = useNewDao({
daoMetadata: { name: 'My DAO', description: 'A great DAO' },
daoUri: 'https://my-dao.example.com',
ensSubdomain: 'mydao',
trustedForwarder: '0x1234...',
plugins: [installData],
})
return (
<>
<button onClick={() => mutate?.()}>"Create DAO"</button>
<p>{creationStatus}</p>
<p>{daoAddress}</p>
<p>{daoTxHash}</p>
</>
)
}
Required Parameters
- Name
daoMetadata
- Type
- DaoMetadata
- Description
The metadata for the new DAO.
- Name
ensSubdomain
- Type
- string
- Description
The ENS subdomain for the new DAO.
- Name
plugins
- Type
- IPluginInstallItem[]
- Description
The plugins to be installed in the new DAO. You must pass at least one plugin.
Optional Parameters
- Name
daoUri
- Type
- string
- Description
The metadata for the new DAO.
- Name
trustedForwarder
- Type
- address
- Description
The address of the trusted forwarder, used for gasless transactions.
Return Data
{
daoAddress: string | null,
daoTxHash: string | null,
}
Return Values
{
mutate: function,
data: NewDaoReturnData | null,
error: Error | null,
creationStatus: 'idle' | 'pinningMetadata' | 'creatingDao' | 'success' | 'error',
daoAddress: string | null,
daoTxHash: string | null,
isLoading: boolean,
isSuccess: boolean,
isError: boolean,
reset: function,
}
onCreateDaoTransaction
callback function that is called when the transaction is sent but not mined yet.
const { mutate, creationStatus, daoAddress, daoTxHash } = useNewDao({
daoMetadata: { name: 'My DAO', description: 'A great DAO' },
daoUri: 'https://my-dao.example.com',
ensSubdomain: 'mydao',
trustedForwarder: '0xTrustedForwarderAddress',
plugins: ['0xPluginEncodedData'],
onCreateDaoTransation(txHash: string) {
alert(`Transaction hash: ${txHash}`)
},
})