# Blockasset Labs Project

<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->

- [Addresses](#addresses)
- [Installation](#installation)
- [Documentation](#documentation)
  - [Create Project](#create-project)
  - [Update Project](#update-project)
  - [Close Project](#close-project)
- [Questions & Support](#questions--support)
- [License](#license)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

## Addresses

Program addresses are the same on devnet, and mainnet-beta.

- Raffle: [`RFLr7rHbJpw7Zvzu554h2AMtm34ng5SkzhytUWch2mb`](https://explorer.solana.com/address/RFLr7rHbJpw7Zvzu554h2AMtm34ng5SkzhytUWch2mb)

## Installation

Installing the package using [yarn](https://yarnpkg.com/lang/en/):

```sh
yarn add @blockassetlabs/project
```

You can also use [npm](https://www.npmjs.com/) instead, if you'd like:

```sh
npm install @blockassetlabs/project
```

🔥 **Pro Tip**: Check out our implementations on ["BlockassetLabs UI" repository](https://github.com/Blockasset/blockasset-labs-ui).

## Documentation

### Create Project

> This is a public transaction, so anybody can create a new project

```ts
import { withInitProject } from "@blockassetlabs/project";

const [transaction, projectId] = await withInitProject(
  new Transaction(),
  connection,
  wallet as Wallet,
  {
    authorities: [wallet.publicKey],
    name: formValues.name,
  },
);
await executeTransaction(connection, wallet as Wallet, transaction);
```

### Update Project

> This transaction can only be called by one of the project authorities

```ts
import { withUpdateProject } from "@blockassetlabs/project";

const transaction = await withUpdateProject(
  new Transaction(),
  connection,
  wallet as Wallet,
  {
    projectId: projectId,
    authorities: [wallet.publicKey],
    name: formValues.name,
  },
);
await executeTransaction(connection, wallet as Wallet, transaction);
```

### Close Project

It's possible to recover the funds used to pay rent for the data stored on-chain by closing the Project.

- Although closing a project will not affect any of its raffles, it's highly recommended to close its raffles first because once the project closed, you will no longer have access to its raffles to modify or close.
- This action is not recoverable and permanently remove the access to the project.

> This transaction can only be called by one of the project authorities

```ts
import { withUpdateProject } from "@blockassetlabs/project";

const transaction = await withCloseProject(
  new Transaction(),
  connection,
  wallet as Wallet,
  {
    projectId: projectId,
  },
);
await executeTransaction(connection, wallet as Wallet, transaction);
```

## Questions & Support

If you are developing using Blockasset contracts and libraries, feel free to reach out for support on Discord. We will work with you or your team to answer questions, provide development support and discuss new feature requests.

For issues please, file a GitHub issue.

> https://discord.gg/blockasset

## License
