Is it possible to send and store asset data to a not yet existing account in a custom tx?

Let’s say I want to store asset:{fruit:apple} in the account 223494L. For now I’ve only stored data in the senders account (which always must exist) or in the tx. But encounter some errors in storing data in a new account. (still got a work around in case this won’t work).

Reply from Corbifex:

Blockquote @korben3 const recipient = await store.account.getOrDefault(this.asset.recipientId); Should get you the existing or a new empty account. You can add your asset

const updatedRecipient = {
 ...recipient,
 asset: { ...recipient.asset, fruit: 'apple' }
}

Thanks! Eventually got it to work, in your code

const recipient = await store.account.getOrDefault(this.asset.recipientId);

I needed to change this.asset.recipientId to this.recipientId … took me a while, haha. Super sneak preview of my new PoC

{"meta":{"offset":0,"limit":10},"data":[{"address":"15001363887974030869L","publicKey":"","balance":"0","secondPublicKey":"","asset":{"poll":{"answers":{"1":"Yes","2":"No"},"question":"Do we buy a new coffee machine?"}}}],"links":{}}

Reply from Corbifex:

I think since v3 you should put recipient in asset although I don’t see a recipient at all in your sneak peak… I like the poc idea you going for @korben3

2 Likes