<span class="token keyword">async</span> <span class="token function">registerAsset</span> <span class="token punctuation">(</span> <span class="token punctuation">)</span> <span class="token punctuation">{</span>
<span class="token keyword">try</span> <span class="token punctuation">{</span>
<span class="token keyword">const</span> accounts <span class="token operator">=</span> <span class="token keyword">await</span> <span class="token keyword">this</span> <span class="token punctuation">.</span> state <span class="token punctuation">.</span> ocean <span class="token punctuation">.</span> accounts <span class="token punctuation">.</span> <span class="token function">list</span> <span class="token punctuation">(</span> <span class="token punctuation">)</span>
<span class="token keyword">const</span> ddo <span class="token operator">=</span> <span class="token keyword">await</span> <span class="token keyword">this</span> <span class="token punctuation">.</span> state <span class="token punctuation">.</span> ocean <span class="token punctuation">.</span> assets <span class="token punctuation">.</span> <span class="token function">create</span> <span class="token punctuation">(</span> asset <span class="token punctuation">,</span> accounts <span class="token punctuation">[</span> <span class="token number">0</span> <span class="token punctuation">]</span> <span class="token punctuation">)</span>
console <span class="token punctuation">.</span> <span class="token function">log</span> <span class="token punctuation">(</span> <span class="token string">'Asset successfully submitted.'</span> <span class="token punctuation">)</span>
console <span class="token punctuation">.</span> <span class="token function">log</span> <span class="token punctuation">(</span> ddo <span class="token punctuation">)</span>
<span class="token comment">// keep track of this registered asset for consumption later on</span>
<span class="token keyword">this</span> <span class="token punctuation">.</span> <span class="token function">setState</span> <span class="token punctuation">(</span> <span class="token punctuation">{</span> ddo <span class="token punctuation">}</span> <span class="token punctuation">)</span>
<span class="token function">alert</span> <span class="token punctuation">(</span>
<span class="token string">'Asset successfully submitted. Look into your console to see the response DDO object.'</span>
<span class="token punctuation">)</span>
<span class="token punctuation">}</span> <span class="token keyword">catch</span> <span class="token punctuation">(</span> <span class="token class-name">error</span> <span class="token punctuation">)</span> <span class="token punctuation">{</span>
console <span class="token punctuation">.</span> <span class="token function">error</span> <span class="token punctuation">(</span> error <span class="token punctuation">.</span> message <span class="token punctuation">)</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>