Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
:contract/fetch-compiled-code
(reg-event-fx
:contract/fetch-compiled-code
interceptors
(fn [{:keys [db]} [on-success]]
{:http-xhrio {:method :get
:uri (gstring/format "/contracts/build/%s.json"
(get-in db [:contract :name]))
:timeout 6000
:response-format (ajax/json-response-format {:keywords? true})
:on-success on-success
:on-failure [:log-error]}}))
(reg-event-fx
:contract/deploy-compiled-code
interceptors
(fn [{:keys [db]} [contracts]]
(let [{:keys [abi bin]} (get-in contracts [:contracts (keyword (:name (:contract db)))])]
{:web3-fx.blockchain/fns
{:web3 (:web3 db)
:fns [[web3-eth/contract-new
(js/JSON.parse abi)
{:gas 4500000
:data bin
:from (first (:my-addresses db))}
:contract/deployed
:log-error]]}})))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment