How SEEDS payments work

Upon clicking Pay with Seeds, a price is quoted in Seeds. We use to get the current SEEDS:TLOS rate, and to get the TLOS:USD rate.

agent =
seeds = JSON.parse(agent.get('', { symbol: 'token.seeds-seeds-tlos' }).body)
telos = JSON.parse(agent.get('').body)
seeds_usd = seeds['symbolInfo']['askPrice'] * telos['telos']['usd']
seeds_value = ( * 100, currency).exchange_to('USD').dollars.to_i / seeds_usd).round

A five-character secret word is generated:

seeds_secret = { [*'a'..'z', *'0'..'9'].sample }.join

We then periodically poll the Telos API to see if a payment has been made with the right memo and amount:

agent =
j = JSON.parse(agent.get("{seeds_username}").body)
j['actions'].each do |action|
next unless action['act'] && (data = action['act']['data'])
next unless data['to'] == seeds_username && data['symbol'] == 'SEEDS' && data['amount'] && !data['memo'].blank? && (seeds_secret = data['memo'].split('SGP: ').last)
if (@order = Order.find_by( => true, :seeds_secret => seeds_secret, :seeds_value => data['amount']))
@order.set(payment_completed: true)

That covers the essential steps.