Publishing
SDK Reference - v0.3.0
This JavaScript/TypeScript SDK allows publishers to serve personalized ads to users based on their Ethereum or EVM-compatible wallet addresses.
Installation
Quick Start
Configuration
Constructor
Creates a new Specify client instance.
Parameters
Parameter | Type | Description |
---|---|---|
config | SpecifyInitConfig | Configuration object |
config.publisherKey | string | Your publisher API key (must start with spk_ and be 34 characters long) |
config.cacheAddressesInLocalSession | boolean | Allows for more efficient serving even after a user disconnects wallet (false by default) |
Example
SDK Reference
serve()
Serves targeted advertising content to specified wallet address(es).
Parameters
Parameter | Type | Description | Required |
---|---|---|---|
addressOrAddresses | Address | Address[] | undefined | Single wallet address or array of wallet addresses. Undefined or empty only works with cacheAddressesInLocalSession = true | Yes |
options | ServeOptions | Configuration options for serving the ad | Yes |
options.imageFormat | ImageFormat | Image format required for placement. Will match best ad with supported image format. See below for all formats. | Yes |
options.adUnitId | string | Id used to identify individual ad placements / units. Useful for performance analytics. | No |
ServeOptions Interface
Returns
Promise<SpecifyAd | null>
- Ad content object or null if no ad is found
Examples
Single wallet address:
With adUnitId:
Multiple wallet addresses - used when you have multiple addresses for one user:
Undefined wallet addresses - With cacheAddressesInLocalSession
we can serve ads even after the user disconnects their wallet:
Image Format Options
The Specify SDK supports three different ad image formats to match your layout needs:
Format | Aspect Ratio | Resolution | Description | Use Case |
---|---|---|---|---|
LANDSCAPE | 16:9 | 640x360 | Wide horizontal format | Hero banners, featured placements |
LONG_BANNER | 8:1 | 728x90 | Extended horizontal banner | Header/footer placements, leaderboards |
SHORT_BANNER | 16:5 | 320x100 | Compact horizontal banner | Inline content, sidebars, mobile banners |
Return Type
When the serve() method successfully finds an ad, it returns a SpecifyAd object with the following properties:
Property | Type | Description |
---|---|---|
walletAddress | string | The wallet address that matched for this ad |
campaignId | string | Unique identifier for the ad campaign |
adId | string | Unique identifier for this specific ad |
headline | string (no markdown) | Ad headline text |
content | string (markdown) | less than 400 characters |
ctaUrl | string | Call-to-action URL |
ctaLabel | string (no markdown) | Call-to-action button text |
imageUrl | string | URL to the ad image |
communityName | string (no markdown) | Name of the advertising community |
communityLogo | string | URL to the community logo |
imageFormat | string | The requested image format (LANDSCAPE, LONG_BANNER, or SHORT_BANNER) |
Content Formatting
The content field in ad responses uses simplified Markdown formatting:
Format | Syntax | Example |
---|---|---|
Bold text |
| Join today for exclusive benefits |
Bullet points |
| * Feature 1\n* Feature 2\n* Feature 3 |
Line breaks |
| First line\nSecond line |
Underlined Text |
| Out now |
Italic Text |
| Italic |
Validation Rules
Publisher Key
Must start with
spk_
Must be exactly 34 characters long
Example:
spk_1234567890abcdef1234567890abcdef
Wallet Addresses
Must be valid Ethereum/EVM-compatible addresses
Must start with
0x
followed by 40 hexadecimal charactersCase-insensitive
Example:
0x742d35Cc6634C0532925a3b8D57C11E4a3e1A510
Address Limits
Minimum: 1 wallet address required
Maximum: 50 wallet addresses per request
Duplicate addresses are automatically removed
Best Practices
Error Handling
Always wrap SDK calls in try-catch blocks and handle specific error types:
Examples
React Integration
Node.js Server Integration
Schedule a call with us
Any other questions? Email us