# Agent

{% hint style="info" %}
The agent entity MUST be created before any agent actions can be performed.
{% endhint %}

Agents are entities that enable greater visibility of the sellers and are compensated for their service. A common example could be a marketplace that shows the seller's offers.

Agents set their fee in percentage points, and if the seller adds them to an offer and the offer is succesfuly fullfiled, the agent is compensated for its service.

{% hint style="info" %}
Agents are not to be confused with AI agent. In the protocol terminology, the agent is only an entity that receives a part of the sale proceeds.
{% endhint %}

Agent's funds management is described in [deposit-and-withdraw](https://docs.bosonprotocol.io/using-the-protocol/dacp-tools/finances/deposit-and-withdraw "mention").

### Solidity

{% tabs %}
{% tab title="Create agent" %}
Creates a marketplace agent.

```solidity
IBosonAccountHandler bosonProtocol = IBosonAccountHandler(_bosonProtocolAddress);

BosonTypes.Agent memory agent = BosonTypes.Agent({
    id: 0, // will be ignored and auto-assigned
    feePercentage: 500, // 5%
    wallet: payable(agentWalletAddress),
    active: true
});

bosonProtocol.createAgent(agent);
```

{% endtab %}

{% tab title="Update agent" %}
Updates a marketplace agent (wallet or fee percentage).

```solidity
IBosonAccountHandler bosonProtocol = IBosonAccountHandler(_bosonProtocolAddress);

BosonTypes.Agent memory agent = BosonTypes.Agent({
    id: 1, // existing agent ID
    feePercentage: 300, // 3%
    wallet: payable(newWalletAddress),
    active: true
});

bosonProtocol.updateAgent(agent);
```

{% endtab %}
{% endtabs %}
