Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ just build-app
{
"Measurements": {
"HashAlgorithm": "Sha384 { ... }",
"PCR0": "9a2f959805a56f8729c48e219591d2db1ec50af35c1c195b13cdc508d6ef81ecb1683fb7aa6f9f5901685f7fd2a95cc7",
"PCR0": "a858981f4dd9399b6de65c021b51631f383a3559b7cc78d44ecf84c9bb43d3640cb6adb6d483bf50200b78d07a975453",
"PCR1": "4b4d5b3661b3efc12920900c80e126e4ce783c522de6c02a2a5bf7af3a2b9327b86776f188e4be1c1c404a129dbda493",
"PCR2": "b8a983e997c911dd5a0ad5bbb3322aa998180e4750b99dd2c6506189816e8de673c4fd46b67658bb05d7b9c936c726d5"
"PCR2": "b2fb1212bba8826d5feccfb6d43a9317d3789851cd6c0c57be241a4cfeef7401cc2e51fb245fbcbf0df153ddebfdd5af"
}
}
```
Expand All @@ -34,16 +34,17 @@ just serve-alpine
just build-test-app make-test-fifos
cp example.env .env
docker compose up -d
just ask-funds
just ask-funds 'why did the worker quit his job at the recycling factory? because it was soda pressing.'
...
addr = wJQASiSgaqVJBP8iQUpyTpNcpQinMWg17unrNTbbYoC
sol = 0.025
addr = Do3F8NmohXPayS3xmos6CmqRXPD9DjCzK8Ct8sCc6UkA
sol = 0.002
json = {
signatute: 'mHPgWppbhKujn8deozVGQurtpqPAcQ1nMg99uSmwmrmSp8m8GPRiXha36D2AJ42bNRzTG9xbhar1w7MRf2mUoLp',
signature: '677Rtf2CcUonuh9f2UJhxLgmiX4EwQrR7vQ6CTydstdTExgqpUtgpy2HPYfmYVZRrYBvFnrQQpbTJW78oVw8zi1h',
from: 'AkHqQ324DvygPxuhyYs9BTVG8b1BXzTnpbCxqG8zousm',
to: 'wJQASiSgaqVJBP8iQUpyTpNcpQinMWg17unrNTbbYoC'
to: 'Do3F8NmohXPayS3xmos6CmqRXPD9DjCzK8Ct8sCc6UkA',
thoughts: "The joke plays on the pun between 'so depressing' and 'soda pressing', which is clever and light-hearted. It evokes a chuckle due to its wordplay."
}
sol = 0.026
sol = 0.003
(look inside node/ask-funds.js)
```

Expand Down
4 changes: 2 additions & 2 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ build-test-app:
add-funds:
{{sudo}} docker run --rm --entrypoint /app/add-funds.sh --env-file .env lockhost-node-test-app

ask-funds:
{{sudo}} docker run --rm --entrypoint /app/ask-funds.sh --network locknet --env-file .env lockhost-node-test-app https://host:8888
ask-funds joke:
{{sudo}} docker run --rm --entrypoint /app/ask-funds.sh --network locknet --env-file .env lockhost-node-test-app https://host:8888 {{joke}}

mkcert:
echo "authorityKeyIdentifier=keyid,issuer" > domains.ext
Expand Down
4 changes: 2 additions & 2 deletions node/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ async function askOpenAi(request, response) {
]

let reply = await oai.chat.completions.create({
model: 'gpt-4o', temperature: 1,
model: 'gpt-4o-mini', temperature: 1,
tools, tool_choice: { type: 'function', 'function': { name: 'record_if_joke_was_funny' }},
messages,
})
Expand Down Expand Up @@ -133,7 +133,7 @@ async function askOpenAi(request, response) {
})

const from = solkey.publicKey.toBase58()
const data = JSON.stringify({ signature, from, to: addr })
const data = JSON.stringify({ signature, from, to: addr, thoughts: reply.thoughts })

writeHead(response, 200)
response.end(data)
Expand Down
16 changes: 8 additions & 8 deletions node/ask-funds.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ function onError(err) {
const testFn = async (PCR, userData) => true

// hit the api and ask oai for funds
async function main(api) {
async function main(api, joke) {
// receiver
const mnemonic = 'test for ask'
const mnemonic = 'seed for test'
const seed = bip39.mnemonicToSeedSync(mnemonic, '')
const solkey = Keypair.fromSeed(seed.subarray(0, 32))
const addr = solkey.publicKey.toBase58()
Expand All @@ -28,7 +28,7 @@ async function main(api) {
console.log(`sol = ${balance}`)

// the funny joke
const message = 'why did the worker quit his job at the recycling factory? because it was soda pressing'
const message = joke
const params = new URLSearchParams({ message, addr })

// attestation doc validation plus encryption
Expand All @@ -41,15 +41,15 @@ async function main(api) {
const data = await response.json()
console.log('json =', data)

// thoughts = reason for denial
if (data.thoughts) { return }
// no signature = no reward
if (!data.signature) { return }

// balance after ask
balance = await sol.getBalance(solkey.publicKey)
balance = balance / LAMPORTS_PER_SOL
console.log(`sol = ${balance}`)
}

const args = process.argv.slice(2)
const [api] = args
main(api).catch(onError)
const api = process.argv.slice(2)[0]
const joke = process.argv.slice(3).join(' ')
main(api, joke).catch(onError)