Call Boson from Solidity in 10 minutes
What you'll build: a Solidity contract that commits to an offer on behalf of its caller. Useful primer for building custom orchestration or composing Boson into another protocol.
Time: 10 minutes. Stack: Foundry. Network: Base Sepolia.
1. Project
forge init boson-onchain
cd boson-onchain
forge install bosonprotocol/boson-protocol-contracts2. The contract
// src/Reseller.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
interface IBosonExchangeCommit {
function commitToOffer(address payable _buyer, uint256 _offerId) external payable;
}
contract Reseller {
address public immutable diamond;
constructor(address _diamond) {
diamond = _diamond;
}
function passThroughCommit(uint256 offerId) external payable {
IBosonExchangeCommit(diamond).commitToOffer{ value: msg.value }(payable(msg.sender), offerId);
}
}3. Find the Diamond address
Look up the Base Sepolia staging Diamond in Networks → Contract addresses. For this quickstart:
DIAMOND=0x... # Base Sepolia staging Diamond address from /networks/addresses4. Deploy and call
forge create src/Reseller.sol:Reseller \
--rpc-url $RPC \
--private-key $PRIVATE_KEY \
--constructor-args $DIAMOND
# Then call:
cast send $RESELLER_ADDR "passThroughCommit(uint256)" $OFFER_ID \
--rpc-url $RPC \
--private-key $PRIVATE_KEY \
--value 1000000000000000000 # 1 ETH if it's a native-token offerCommon gotchas
- ERC-20 offers require allowance on the Diamond before the inner
commitToOfferis called. Pull the buyer's tokens to your contract first, approve the Diamond, then call. - The Diamond exposes all facets at the same address. Cast it to whichever interface you need.
- NatSpec is the source of truth. Browse the facet sources for full docs.
Next
- Reference → Contracts → Diamond facets for the full callable surface.
- Concepts → Architecture for how the Diamond is laid out.
- Build → Sellers if you want to do this from TypeScript instead.