Settings

Blockchain
Network
Unit
Language
Theme
Sound New Block

Transaction

0f8a2c0b5c75cb3eded3d23b890beb20e6cb398cfb805e4e5b36c8333d96226a
Timestamp (utc)
2021-02-17 21:25:10
Fee Paid
0.00011240 BSV
(
0.00426813 BSV
-
0.00415573 BSV
)
Fee Rate
503.1 sat/KB
Version
1
Confirmations
316,080
Size Stats
22,341 B

3 Outputs

Total Output:
0.00415573 BSV
  • jrun cryptofightsMAV{"in":0,"ref":["4a4466c7a9318d0558bbcf5d6b6a23fad6df493a37375d12cc5a2d0f93ebfb10_o1","c3fb034a1a3d1f8148a7b97a32eeb8e01a70df509d672ab515680d18dbd2a2fb_o1","e68059b9fa0ab585eba3c56aa74c19f6995ab0a58949cbe38c8e196d0aa42e5c_o1","a34d00702f70ed911602954d859feb8d66d40e5cf4b01eb30f375becb3d40af3_o1","02fe9cef12f9d0c7cb373b45d3df70c6733b16b3db9c12f19f156246f66d3183_o1","45f729a90fec143a9d1ed6afec715df04241524af856ce122182deb614ac9019_o1","cae1256e5e9c6a7603cb3b12e5440274a1c0d4f01ce0f259996802e0e4cad3f9_o1","63c45ae941c9458d0b98d581c78152c6b6a9b6e8d41ca852192e78e7a2348775_o1","c94768023418325bdb7e8f5126e9a08e96160ba7555627188fe620457fa14cce_o1","3e5e3661f9ca5aacaeae49cd7e85421537c163d8d49d38451a8f451ae9951726_o1","ff55919f80b34dc2aa9153026438c0f93026a81d5c53494f8203d791b0cadc79_o1","6939b560abd6d2031fc50417abea833a30c09080b5bd0766a19ea1489430a852_o1","f9a7565a637b489502dfe8dbb0745175354a3d47ee03c10dc4ce4acb238f822e_o1","507b9cffbeb94c2386e054f3d63617f7b091e0bdb1619a99c3cd04e309be45f3_o1","b61ceaab3690af8868f1b305d30b9ea37688681de59732610963091f7b8277da_o1","91e2e3cb089c8342223d40abadab69c7fdc192e146a7a33c4638515159bc0b7d_o1","b2ddb06a8acf4f6e7f594d812982ef6a924390d6e898a83140aa58606b1d2d05_o1","680f3466e50d3349a9e59e4d3b6440e418fcda44be4a52143174cca22d164a2b_o1","0135ed4bc6a365330506c2547d3984945952c8fc9a2cb64226fe443ab7ceba0a_o1","589e107231b17445bc648ace9e1a852d201409a3ed42280c3f5ff4033c1a28ac_o1","d1b20b4e254b2ba463518c80aaa7610e125d4dadb79162780ed2c5aee65ef24a_o1","4265da657b40362a30db8f71151d1502c97ccfcdb9876f13dcd935e122fa8dbd_o1","dfdfd3e338ba8e109e57f0f584ec238a17bfbcdb789d6bb0a93969dfa75da9ba_o1"],"out":["0ac525a2677794b420b15d2ddf0995e4d95952b6015684595efcf70f341ed206"],"del":[],"cre":["n2Bd4cWhEQK1aVjb1R7EBGV9mrw3etvSdC"],"exec":[{"op":"DEPLOY","data":["class ClientAgent extends Agent {\n async init() {\n this.jigHandlers.set(Fighter.origin, this.onFighter);\n this.jigHandlers.set(KronoCoin.origin, this.onKronoCoin);\n this.jigHandlers.set(KronoItem.origin, this.onItem);\n\n this.messageHandlers.set('BattleCreated', this.onBattleCreated);\n this.messageHandlers.set('BattleUpdated', this.onBattleUpdated);\n this.messageHandlers.set('BattleCompleted', this.onBattleCompleted);\n this.messageHandlers.set('ActionError', this.onActionError);\n this.messageHandlers.set('ExitQueue', this._exitQueue);\n this.messageHandlers.set('SignBattle', this.signBattle);\n this.messageHandlers.set('QueueStatus', this._queueStatus);\n this.messageHandlers.set('Requeue', this._enqueue);\n\n this.eventHandlers.set('Act', this.Act);\n this.eventHandlers.set('CreateFighter', this.CreateFighter);\n this.eventHandlers.set('EnterQueue', this.EnterQueue);\n this.eventHandlers.set('ExitQueue', this.ExitQueue);\n this.eventHandlers.set('Forfeit', this.Forfeit);\n this.eventHandlers.set('GetFighters', this.GetFighters);\n this.eventHandlers.set('SimulateFighterState', this.SimulateFighterState);\n this.eventHandlers.set('SimulateFightersState', this.SimulateFightersState);\n this.eventHandlers.set('GetItems', this.GetItems);\n this.eventHandlers.set('GetPlayer', this.GetPlayer);\n this.eventHandlers.set('GetBattles', this.GetBattles);\n this.eventHandlers.set('GetBalance', this.getBalance);\n this.eventHandlers.set('GetBattleHistory', this.GetBattleHistory);\n this.eventHandlers.set('GetLastBattleUpdated', this.GetLastBattleUpdated);\n \n this.eventHandlers.set('LevelUp', this.LevelUp);\n this.eventHandlers.set('RedeemItem', this.RedeemItem);\n\n const lock = new CoinLock(this.wallet.ownerPair.pubKey.toString());\n this.coinScript = lock.script();\n console.log('COIN SCRIPT:', this.coinScript);\n this.emit('subscribe', this.coinScript);\n\n this._battles = new Map();\n this._fighters = new Map();\n this._items = new Map();\n this.emit('subscribe', 'QueueStatus');\n // this.wallet.setTimeout(() => this.recordVictories(), 0);\n // this.wallet.setTimeout(() => this.dispose(), 0);\n }\n\n onFighter(fighter) {\n this._fighters.set(fighter.origin, fighter.toObject());\n this.emit('client', 'FighterUpdated', this._fighters.get(fighter.origin));\n }\n\n onItem(item) {\n this._items.set(item.origin, item.toObject());\n this.emit('client', 'ItemUpdated', this._items.get(item.origin));\n }\n\n async onKronoCoin() {\n this.emit('client', 'BalanceUpdated', await this.getBalance());\n }\n\n onBattleCreated(message) {\n const { id } = message.payloadObj;\n if(id === this.currentId) {\n delete this.queueMessage;\n }\n this.emit('client', 'BattleCreated', message.payloadObj);\n console.log(`BattleCreated: ${message.payload}`);\n }\n\n _queueStatus(message) {\n this.emit('client', 'QueueStatus', message.payload);\n }\n\n async onBattleUpdated(message) {\n this.emit('client', 'BattleUpdated', message.payloadObj);\n console.log(`BattleUpdated: ${message.payload}`);\n const { location, battleId } = message.payloadObj;\n\n console.log('Handling BattleUpdated - BU:', battleId, ' CURR:', this.currentId);\n if(battleId === this.currentId) {\n console.log('Updating battleLocation');\n this.battleLocation = location;\n }\n }\n\n async onBattleCompleted(message) {\n const { location, battleId } = message.payloadObj;\n const battle = await this.wallet.loadJig(location);\n this._battles.set(battle.origin, battle.toObject());\n \n if (battleId === this.currentId) {\n const battleState = battle.getState();\n this.emit('client', 'BattleUpdated', battleState);\n console.log(`BattleUpdated: ${JSON.stringify(battleState)}`);\n this.emit('client', 'BattleCompleted', this._battles.get(battle.origin));\n console.log('BattleCompleted', this._battles.get(battle.origin));\n console.log(`BattleCompleted: ${JSON.stringify(this._battles.get(battle.origin))}`);\n // delete this.battle;\n // delete this.currentId;\n }\n\n if(battle.owner === this.address) {\n const { fighter } = battle.victor;\n fighter.recordVictory(battle);\n await fighter.sync();\n this.onFighter(fighter);\n }\n }\n\n async recordVictories() {\n console.log('Record Victories');\n try {\n const battles = await this.wallet.loadJigIndex({\n criteria: {kind: Battle.origin},\n project: {value: false}\n });\n for(let b of battles) {\n const battle = await this.wallet.loadJig(b.location);\n await battle.victor.fighter.sync();\n battle.victor.fighter.recordVictory(battle);\n await battle.victor.fighter.sync();\n this.onFighter(battle.victor.fighter);\n }\n } catch(e) {\n console.error('Record Victories Error:', e.message);\n }\n }\n\n async signBattle(message) {\n console.log('signBattle');\n if (!this.queueMessage || !message.context.includes(this.queueId)){\n console.log('Invalid Queue:', this.queueMessage, this.queueId);\n return;\n } \n const { id, rawtx } = message.payloadObj;\n console.log(`Client-Agent - signBattle: id = ${id}, rawtx = ${rawtx}`);\n const { Br, Tx} = this.bsv;\n let tx = this.bsv.Tx.fromHex(rawtx);\n console.log(`Client-Agent - signBattle: tx = ${tx}`);\n const outputs = await Promise.all(tx.txIns.map(async txIn => {\n const txid = new Br(txIn.txHashBuf).readReverse().toString('hex');\n const outTx = Tx.fromHex(await this.blockchain.fetch(txid));\n return {\n location: `${txid}_o${txIn.txOutNum}`,\n script: outTx.txOuts[txIn.txOutNum].script.toString(),\n };\n }));\n console.log('OUTPUTS:', JSON.stringify(outputs, null, 2));\n const t = await this.wallet.loadTransaction(rawtx);\n console.log(`Executed wallet.loadTransaction.`); // Added debug log #1\n \n const rules = ClientAgent.lobbies.find(lobby => lobby.origin === this.queueMessage.subject);\n console.log(`Executed ClientAgent.lobbies.find.`); // Added debug log #2\n if (!rules) throw new Error('Invalid Lobby');\n console.log(`Lobby is valid`); // Added debug log #3\n const newRawTx = await t.export({sign: true, pay: false});\n console.log(`Executed t.export.`);// Added debug log #4\n tx = this.bsv.Tx.fromHex(newRawTx);\n console.log(`Executed this.bsv.Tx.fromHex(newRawTx).`);// Added debug log #5\n let sigs = tx.txIns.map(txIn => txIn.scriptVi.toNumber() && txIn.script.toString());\n console.log('SIGS AFTER:', sigs);\n\n this.currentId = id;\n const sigMessage = this.wallet.buildMessage({\n to: [message.from],\n subject: 'BattleSigned',\n context: [id],\n payload: JSON.stringify({\n id,\n sigs\n })\n });\n await this.blockchain.sendMessage(sigMessage);\n }\n\n async Act(request) {\n console.log('Act', JSON.stringify(request));\n const { actionIndex } = request;\n const battle = await this.wallet.loadJig(this.battleLocation);\n if(!battle) {\n console.log('No Battle');\n } else {\n console.log('ACT BATTLE:', battle.toObject());\n }\n const {id, location} = battle;\n const message = this.wallet.buildMessage({\n context: [id],\n subject: 'Act',\n payload: JSON.stringify({ location, actionIndex })\n });\n await this.blockchain.sendMessage(message);\n }\n\n async onActionError(message) {\n throw new Error(message.payload);\n }\n\n async CreateFighter(request) {\n delete request.skills;\n const message = this.wallet.buildMessage({\n to: [MintConfig.pubkey],\n subject: 'FighterRequest',\n context: [this.currentId],\n payload: JSON.stringify({\n ...request,\n owner: this.address\n })\n });\n const resp = await this.blockchain.sendMessage(message, MintConfig.postTo);\n const fighter = await this.wallet.loadJig(resp.location);\n this.onFighter(fighter);\n return fighter;\n }\n\n async EnterQueue(request) {\n const rules = ClientAgent.lobbies[request.lobbyId-1];\n console.log('RULES:', rules && rules.origin);\n const fighter = await this.wallet.loadJig(request.fighterLocation);\n if(!fighter) throw new Error('CLIENT: Invalid Fighter');\n console.time('Fighter Sync');\n await fighter.sync({inner: false});\n console.timeEnd('Fighter Sync');\n const items = await Promise.all(request.itemLocations.map(async location => {\n if(!location) return null;\n const item = await this.wallet.loadJig(location);\n if(!item) return;\n console.time(`Item Sync: ${location}`);\n await item.sync({inner: false});\n console.timeEnd(`Item Sync: ${location}`);\n return item;\n }));\n\n const skills = request.actionIds;\n console.log('Load Coin');\n let coins = await this.selectCoins(rules.fee);\n\n console.log('Build Message');\n this.queueMessage = {\n to: [QueueConfig.pubkey],\n subject: rules.origin,\n payload: JSON.stringify({\n pubkey: this.pubkey,\n owner: this.address,\n fighterLocation: fighter.location,\n itemLocations: items.map(i => i && i.location),\n skills,\n coinLocations: coins.map(c => c.location)\n })\n };\n \n await this._enqueue();\n return request.lobbyId;\n }\n\n async _enqueue() {\n if(!this.queueMessage) return;\n const message = this.wallet.buildMessage(this.queueMessage);\n this.queueId = message.id;\n console.log('_enqueue:', message.id);\n \n await this.blockchain.sendMessage(\n message,\n QueueConfig.postTo\n );\n this.wallet.setTimeout(async () => this._refreshQueue(message.id), 45000);\n }\n\n async _refreshQueue(queueId) {\n if(this.queueId !== queueId || !this.queueMessage) return;\n try {\n const refreshed = await this.blockchain.sendMessage(\n this.wallet.buildMessage({\n to: [QueueConfig.pubkey],\n subject: 'RefreshQueue',\n payload: JSON.stringify({queueId})\n }),\n QueueConfig.postTo\n );\n console.log('Refreshed:', refreshed);\n if(refreshed) this.wallet.setTimeout(async () => this._refreshQueue(queueId), 45000);\n else {\n console.log('Queue expired.');\n // this.emit('client', 'OnExitQueue', 'Refresh expired');\n }\n } catch(e) {\n console.error('Refresh Queue Error:', e.message);\n }\n }\n\n async ExitQueue() {\n const message = this.wallet.buildMessage({\n to: [QueueConfig.pubkey],\n subject: 'ExitQueue'\n });\n await this.blockchain.sendMessage(message, QueueConfig.postTo);\n this._exitQueue();\n }\n\n async _exitQueue(message) {\n delete this.queueMessage;\n this.emit('client', 'OnExitQueue', message && message.payload);\n if(message && message.payload) {\n this.emit('client', 'Error', message.payload);\n }\n }\n\n async Forfeit() {\n const message = this.wallet.buildMessage({\n to: [ValidatorConfig.pubkey],\n context: [this.currentId],\n subject: 'Forfeit',\n payload: JSON.stringify({ location: this.battleLocation })\n });\n await this.blockchain.sendMessage(message);\n }\n \n \n async GetBattles() {\n if(!this.historyLoaded) {\n const tokens = await this.blockchain.jigQuery({ \n criteria: {\n kind: BattleToken.origin,\n owner: this.address\n },\n limit: 20,\n sort: {ts: -1}\n });\n console.log('Tokens:', tokens.length);\n await Promise.all(tokens.map(async t => {\n const token = await this.blockchain.loadJigData(t.location);\n console.log(`Token: ${JSON.stringify(token)}`);\n if(token && token.value) {\n this._battles.set(token.value.battle.origin, token.value.battle);\n }\n }));\n this.historyLoaded = true;\n }\n console.log('Battles:', this._battles.size);\n return [...this._battles.values()];\n }\n\n async GetFighters() {\n if(!this._fighters.size) {\n const index = await this.wallet.loadJigIndex({\n criteria: {kind: Fighter.origin}\n });\n index.forEach(f => this._fighters.set(f.origin, f.value));\n }\n return [...this._fighters.values()];\n }\n\n SimulateFighterState(message) {\n return BattleUtils.simulateFighterState(message);\n }\n\n SimulateFightersState(message) {\n const fighterStates = [];\n message.forEach(f => fighterStates.push(BattleUtils.simulateFighterState(f)));\n return fighterStates;\n }\n\n async GetLastBattleUpdated() {\n if(!this.battleLocation) return;\n const battle = await this.wallet.loadJig(this.battleLocation);\n return battle.getState();\n }\n\n async GetItems() {\n if(!this._items.size) {\n const index = await this.wallet.loadJigIndex({\n criteria: {kind: KronoItem.origin},\n project: {'value.mint': false}\n });\n index.forEach(i => this._items.set(i.origin, i.value));\n }\n return [...this._items.values()];\n }\n\n async GetPlayer() {\n const [fIndex, iIndex,] = await Promise.all([\n this.wallet.loadJigIndex({criteria: {kind: Fighter.origin}, project: {value: false}}),\n this.wallet.loadJigIndex({criteria: {kind: KronoItem.origin}, project: {value: false}})\n ]);\n\n const balance = await this.getBalance();\n const config = {\n address: this.address,\n pubkey: this.pubkey,\n owner: this.address,\n handle: this.wallet.handle,\n balance,\n xpTable: {\n cumulativeXp: Fighter.LevelUpXP,\n xpPerKill: Battle.LevelXPReward\n },\n lobbiesPerLevel: Fighter.LobbiesPerLevel,\n tierPerLobby: Fighter.TierPerLobby,\n abilityScoreLevels: Fighter.AbilityScoreLevels,\n skillLevels: Fighter.SkillLevels,\n skills: Object.entries(Constants.SkillData).map(([k, v]) => {\n if(['location', 'origin', 'owner', 'nonce', 'deps', 'satoshis'].includes(k)) return;\n return {\n ...v,\n skillType: k\n };\n }).filter(x => !!x),\n fighterCount: fIndex.length,\n itemCount: iIndex.length,\n lobbies: KronoClass.deepClone(this.constructor.lobbies)\n };\n\n return config;\n }\n\n async LevelUp(request) {\n const { fighterLocation, ability, skillType } = request;\n let fighter = await this.wallet.loadJig(fighterLocation);\n if(!fighter) throw new Error('Invalid Fighter');\n await fighter.sync();\n\n const rawtx = await this.blockchain.sendMessage(this.wallet.buildMessage({\n subject: 'LevelUp',\n payload: JSON.stringify({\n fighterLocation: fighter.location,\n ability,\n skillType\n })\n }), MintConfig.postTo);\n\n const t = await this.wallet.loadTransaction(rawtx);\n fighter = t.outputs.find(o => o instanceof Fighter);\n await t.publish();\n await fighter.sync();\n // this.onFighter(fighter);\n return fighter.toObject();\n }\n\n async RedeemItem(itemId) {\n const message = this.wallet.buildMessage({\n to: [MintConfig.pubkey],\n subject: 'RedeemItemRequest',\n payload: JSON.stringify({owner: this.address, itemId})\n });\n\n const item = await this.blockchain.sendMessage(message, MintConfig.postTo);\n this._items.set(item.origin, item);\n return item;\n }\n\n async dispose() {\n const index = await this.wallet.loadJigIndex({ project: { value: false } });\n const deprecated = index\n .filter(data => !this.constructor.whitelist.includes(data.kind))\n .slice(0, 50);\n if (!deprecated.length) return;\n for (const j of deprecated) {\n try {\n const jig = await this.wallet.loadJig(j.location);\n await jig.sync({inner: false});\n console.log('Disposing:', jig.constructor.name, jig.location);\n jig.destroy();\n await jig.sync({forward: false});\n } catch(e) {\n console.error('Dispose Error:', e.message, e.stack);\n }\n }\n }\n\n static async preDeploy() {\n ClientAgent.lobbies = [\n ClientAgent.deps.Bot1ValidatorAgent,\n ClientAgent.deps.Bot2ValidatorAgent,\n ClientAgent.deps.Bot3ValidatorAgent,\n ClientAgent.deps.Bot4ValidatorAgent,\n ClientAgent.deps.Bot5ValidatorAgent,\n ClientAgent.deps.Bot6ValidatorAgent,\n ClientAgent.deps.Tier7ValidatorAgent,\n ];\n\n ClientAgent.whitelist = [\n ClientAgent.deps.Battle.origin,\n // ClientAgent.deps.BattleToken.origin,\n ClientAgent.deps.Fighter.origin,\n ClientAgent.deps.KronoItem.origin,\n ClientAgent.deps.KronoCoin\n ];\n }\n}",{"agentId":"client","deps":{"Agent":{"$jig":0},"Battle":{"$jig":1},"BattleToken":{"$jig":2},"BattleUtils":{"$jig":3},"Bot1ValidatorAgent":{"$jig":4},"Bot2ValidatorAgent":{"$jig":5},"Bot3ValidatorAgent":{"$jig":6},"Bot4ValidatorAgent":{"$jig":7},"Bot5ValidatorAgent":{"$jig":8},"Bot6ValidatorAgent":{"$jig":9},"CoinLock":{"$jig":10},"Constants":{"$jig":11},"Fighter":{"$jig":12},"KronoClass":{"$jig":13},"KronoCoin":{"$jig":14},"KronoError":{"$jig":15},"KronoItem":{"$jig":16},"MintConfig":{"$jig":17},"QueueConfig":{"$jig":18},"Sha256":{"$jig":19},"Tier7ValidatorAgent":{"$jig":20},"ValidatorConfig":{"$jig":21},"XpTest":{"$jig":22}},"hash":"e9743af3af64e86a6ca2bf7244dc102ff542559dcd2bee8f51e7bd4dfb622e4c","lobbies":[{"$dup":["1","deps","Bot1ValidatorAgent"]},{"$dup":["1","deps","Bot2ValidatorAgent"]},{"$dup":["1","deps","Bot3ValidatorAgent"]},{"$dup":["1","deps","Bot4ValidatorAgent"]},{"$dup":["1","deps","Bot5ValidatorAgent"]},{"$dup":["1","deps","Bot6ValidatorAgent"]},{"$dup":["1","deps","Tier7ValidatorAgent"]}],"sealed":false,"whitelist":["c3fb034a1a3d1f8148a7b97a32eeb8e01a70df509d672ab515680d18dbd2a2fb_o1","f9a7565a637b489502dfe8dbb0745175354a3d47ee03c10dc4ce4acb238f822e_o1","b2ddb06a8acf4f6e7f594d812982ef6a924390d6e898a83140aa58606b1d2d05_o1",{"$dup":["1","deps","KronoCoin"]}]}]}]}
    https://whatsonchain.com/tx/0f8a2c0b5c75cb3eded3d23b890beb20e6cb398cfb805e4e5b36c8333d96226a