What is Gamba?
Gamba is a decentralized betting platform on Solana. It allows anyone to build on-chain casino games without deploying any backend code or providing any of their own liquidity.
When users play on your app you automatically collect royaltees.
Code example
Here's a very simple example where the player has a 50/50 chance of doubling their money. By changing the creator
property to your own wallet address, all bets made in your app will earn you royaltees.
import React from 'react'
import { Gamba, useGamba } from 'gamba/react'
function DoubleOrNothing() {
const gamba = useGamba()
const play = async () => {
// Request user to sign transaction
const request = await gamba.play({
bet: [0, 2], // 0x or 2x
wager: 1e9 * 0.1, // 0.1 SOL
})
// Await the result
const result = await request.result()
// ... Visualize the result however you want
}
return (
<>
<button onClick={play}>
Double or Nothing
</button>
{gamba.user.balance > 0 && (
<button onClick={() => gamba.withdraw()}>
Claim {gamba.user.balance / 1e9} SOL
</button>
)}
</>
)
}
function App() {
return (
<Gamba creator="<PUBLIC KEY>">
<DoubleOrNothing />
</Gamba>
)
}
Getting started
If you're new and want to get something out quickly we suggest you browse our templates and work from there. Otherwise the documentation is a good place to get a better understanding of how it works.