> For the complete documentation index, see [llms.txt](https://bify.gitbook.io/rwa-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://bify.gitbook.io/rwa-docs/bify-sdk/access-voting.md).

# Access Passes and Voting

BIFY Commerce contracts support optional access entitlements and one-vote-per- wallet polls. These capabilities are configured by the partner backend and used by the customer through the browser SDK or a direct EIP-1193 wallet provider.

## Create an access pass

The `issuerId` is the approved Commerce issuer identifier configured for the partner. It is not a product ID and does not create a BIFY product registry.

```ts
const access = await bify.access.create({
  accessId: "0x1111111111111111111111111111111111111111111111111111111111111111",
  issuerId: "0x2222222222222222222222222222222222222222222222222222222222222222",
  metadataURI: "https://merchant.example/access/club-2026.json",
  metadataHash: "0x3333333333333333333333333333333333333333333333333333333333333333",
});

await bify.access.grant(
  access.id,
  "0x1234567890123456789012345678901234567890",
);
```

The partner can pause or reactivate the pass and revoke a wallet grant:

```ts
await bify.access.setActive(access.id, true);
await bify.access.revoke(
  access.id,
  "0x1234567890123456789012345678901234567890",
);
```

## Check access in the browser

Use the contract address returned by the BIFY environment configuration. The check is evaluated on-chain and should be repeated when the protected action is attempted.

```ts
import {
  checkAccess,
  ensureChain,
  requestAccounts,
} from "@bify/commerce-widget";

const provider = window.ethereum;
await ensureChain(provider, 84532); // Base Sepolia; use 8453 in production.
const wallet = await requestAccounts(provider);
const allowed = await checkAccess(
  provider,
  accessRegistryAddress,
  access.id,
  wallet,
);

if (!allowed) {
  throw new Error("This wallet does not have an active entitlement.");
}

openPartnerGatedExperience();
```

Do not treat a partner database grant as sufficient proof for an on-chain protected action. Check the registry state at the point of access.

## Create a poll

```ts
const poll = await bify.voting.createPoll({
  pollId: "0x4444444444444444444444444444444444444444444444444444444444444444",
  issuerId: access.issuerId,
  accessId: access.id,
  metadataURI: "https://merchant.example/polls/design.json",
  metadataHash: "0x5555555555555555555555555555555555555555555555555555555555555555",
  optionCount: 3,
});

await bify.voting.setPollActive(poll.id, true);
```

The contract enforces the option range, active period, optional access pass, and one vote per wallet.

## Cast and read a vote

```ts
import {
  castVote,
  checkVote,
  readVotes,
} from "@bify/commerce-widget";

const voter = await requestAccounts(window.ethereum);
if (await checkVote(window.ethereum, votingAddress, poll.id, voter)) {
  throw new Error("This wallet has already voted.");
}

const receipt = await castVote(
  window.ethereum,
  votingAddress,
  poll.id,
  1, // zero-based option index
  voter,
);

const optionOneVotes = await readVotes(
  window.ethereum,
  votingAddress,
  poll.id,
  1,
);
console.log(receipt.transactionHash, optionOneVotes.toString());
```

Wallet transactions are user-authorized. The partner backend should use the `voting.poll.created` and `voting.poll.status_changed` events for operational state, while the contract remains the authority for vote eligibility and counts.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://bify.gitbook.io/rwa-docs/bify-sdk/access-voting.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
