const Arweave = require("arweave");
const {readContract} = require("smartweave");
const fs = require("fs");
const path = require("path");
const stringify = require("safe-stable-stringify");

const arweave = Arweave.init({
  host: "arweave.net",
  port: 443,
  protocol: "https",
});

const contracts =
  [
    "Daj-MNSnH55TDfxqC7v4eq0lKzVIwh98srUaWqyuZtY",
    "t9T7DIOGxx4VWXoCEeYYarFYeERTpWIC1V3y-BPZgKE",
    "5pSyVjFI07z8mbLeQhYBMsQ4M_MPidXIGX6T77rnF2s",
    "-8A6RexFkpfWwuyVO98wzSFZh0d6VJuI-buTJvlwOJQ",
    "AVTqjPQGCCXim7Nl_gn3HMjE4k0Zi_eTFRJCNEVXZxw",
    "6eTVr8IKPNYbMHVcpHFXr-XNaL5hT6zRJXimcP-owmo",
    "mzvUgNc8YFk0w5K5H7c8pyT-FC5Y_ba0r7_8766Kx74",
    "U75PzAt0XWyH1HCd0gkHAFiWBIx-1dEyj33f2euHLYs",
    "SJ3l7474UHh3Dw6dWVT1bzsJ-8JvOewtGoDdOecWIZo",
    "ydjfv0hRQdD2c-MASv4L5Qahjap_LXJyD9tNyKWvf50",
    "c25-RdheC6khcACLv23-XXg1W7YuA-VSZ_1_qnNFbhw",
    "ZT-70ovBlkF6cRIqvyHy5lC2LcjudsmCz9z19M4_QC4",
    "o-qJmQ4B0d6TnyA_awjhiBdiq0O4Vt_dNWU3pTnhTu8",
    "BYRf00nIE4pGkJ8GyUY2PIJ1rBtxFPoWIu-0dd8iukg",
    "5NgGX4OToJ4M5ohWP4yxaTz_2oPsnk7vmR0v3mqXi_A",
    "4o-2xMPa45BXjGuII_LbOMQWfhE1F0qugdEUZvRlXRY",
    "eWB7FHyPyCYnkcbK1aINbAQ9YYTDhKGkS7lDiNPZ5Mg",
    "oVUvLJ8dEMtOldu9JF3n-cA5tsO7Gel9MNGPPu2XFUA",
    "dlKReXkvj7Af-mc_0DiY_2OQIVot_mUcc6YAzH9vo3s",
    "9BX6HQV5qkGiXV6hTglAuPdccKoEP_XI2NNbjHv5MMM",
    "lbHyzjQH4oZ4JxYuYzY20iLYEe4mX1p7ApU-S2Ew218",
    "UvjBvJUy8pOMR_lf85tBDaJD0jF85G5Ayj1p2h7yols",
    "f1wibc4fPQbcOtHR9ZlcfiJZicJSHA2mgETC-3WHMME",
    "FdY68iYqTvA40U34aXQBBYseGmIUmLV-u57bT7LZWm0",
    "usjm4PCxUd5mtaon7zc97-dt-3qf67yPyqgzLnLqk5A",
    "UjZ6sg7KvoF1XoW7ReB2X3P5uHAbCWYaUIzB7XrjTtM",
    "nxZu3_PWyO_4w2Q7mX2NxpBmEFp5a_Q2bv8CWfDfOjo",
    "p04Jz3AO0cuGLzrgRG0s2BJbGL20HP1N8F9hsu6iFrE",
    "HJfFTVxB0kSkr2Q5soVYtoMN4nZd-WZHs1Kv0g2lHuY",
    "q6SQ0dcSAJmKChrIMGiG3St9YF4VF_3ilbGt51YGQIk",
    "sew_MAXZIgmyEPzzOTkdAca7SQCL9XTCMfxY3KOE5-M",
    "S3a-4VByScX0vtjmh5oZPs8kHTNn-8UPFVOkm2RprDc",
    "BAfcKVhykkup_onxxgzj3T0fMhp33bY82OK23Rruy-Q",
    "dpRwKqXGO234CgHp5i_zr0Vv-caoej-EWd9cpQVcYhA",
    "4BM86e-zd_XBSY4nFFH3Kz_9GY2jkcEmnxe7CKqONIw",
    "QIa535saTE2QBSKwAdV1ChxoH--t4liW49twzZAW7JM",
    "OA2AH-uyk6IakJDTQhgUaAf5PWaSGJgWz178C1aYDL4",
    "a3WZd4Fa9gckxRqDyu-EAONy7v25J8kuqj75ZgtGoUg",
    "CbGCxBJn6jLeezqDl1w3o8oCSeRCb-MmtZNKPodla-0",
    "lmOgf5O5wNiFi45rL5QMkB-bAEF5c-Yc0IZyoSCV-eU",
    "KeOt45twVd0UwSmiY7SteZXuvwBiixb8XaAkXVs3ePE",
    "PiM6NAml7owLgLkGafrfT662rkBh0n_PD7ltEEpI3aw",
    "_iDpkuu4caqtRKa2LUIaWfESzD4pe2aJRWGTDG0xTUc",
    "HWSbM2l-1gsBzCQMjzoP6G4aKafJvDeHyLs5YdTDxm0",
    "K9Lb5WzRHxGyQqZVKL-ckBcnwtEouEBOlphKNmLhHtY",
    "sdOMIHnYrrco6rnl_yJGZirqO54SMhxhdGV9RC8xyyY",
    "YN7VDKn_JjziC4tTL92K9pO_iMcnMSjk6kgSBr1EPjI",
    "Wvp7APAOzwz_ZGxFmvAiVTGhKB47DRvI2yFmOqHW0e8",
    "mG-20tH4-wpDMsD1sl6QjkpoxpXxCT119boFtNfPztw",
    "l4iqeiSb4oJrpByg6rgiXlW1iF3cgjXLbHdG2JvAC_c",
    "7hVrRtwjs7XLPtpZsQMr6RPz19QjtTqQYpHy3rPEy-4",
    "-aH2NkyNNODmaIyoNmPW1RqNmhirZgAQHYKXbpr1RtY",
    "Wgp3SpOtWXGCi1SardwQAwrOsQeW6aQn36ooo6eo8nc",
    "pnTOOL1MebQ-c4Dw4zgMKvCdPbvsCC7JTTDmEjAr0qI",
    "bG4FzHB19RclVEU3pimgtw1oijono0y-XfDRZR_Nlhc",
    "bkRi0K8DADQW9TNOpbYtV53EzvRwT9LLwZPGyCwJaAg",
    "W_84yhLuUptuBi4qTUChiAE2wtHOOvTdqvj3IYfU6gg",
    "yowLo9OICoqnUJNwt55a0uZ_zrnV01laKReWUJWZyjA",
    "MyTcxU4CpV7NKV0sTX6NNSQR2UhhIhzcjiRHLC4qluc",
    "CpFzxta1dGIuMGkIlV50tA-NhJFcTsNDrvECQ6cg3_M",
    "dg5m4ejxOCA84vAqRk9AhNumyeg3zCmGgg0sIeWoZkU",
    "fN-nTV-Q6HX9wDPNo89CKpbUhC6nDLWlnic7QzRA1g0",
    "l2uG_a4IoB3D910lpk2K30enL0rapLbH0GNt5O-PAdA",
    "bBKWTDtnqYsk2jgWBQNhOnZzGWpXIvgg6l4yU4aqlXY",
    "zBnoI4RYhs0g6WblVebJhEu0nolyiHBz3MegSyYcu0A",
    "0hUxw3Ah1roZ2HR_E56IqxoV1qvaj1W_Wr-8PTocsd0",
    "u7m6WwapDKXhcKmN1OrZW1VGtXWalm-C4QqHZNYIwug",
    "uBAtZUaLK8rolhSILgfxG_UGU2GcvawhdQjid3K5oE4",
    "bNmbXC1rJoepS9crl26imkFgiqg-uLFXBcfILuW0Aok",
    "UGG1xAjpBU2gq66elzgiT_r1obYkwuoxO80YJ97n5dk",
    "XmTFbgqgXi1SvgpbsbcxO7TWX6RtczIpzTF-IiNA1Lc",
    "cpXtKvM0e6cqAgjv-BCfanWQmYGupECt1MxRk1N9Mjk",
    "suEGI_H1NjKhPZVfOJxRTS8sSzaeSMAIZqLfCbSAVj8",
    "RRvgew0V1aQzlgY3olVi9WPLojBGNR_jrwDkfyXHtyI",
    "mpuVOVsDjH-dazsC3CNlDHiqvVQdydCElVrgcJvkl_o",
    "qGNZGZBNv5JffEPkkuYpHEOEtZYHLhrRrRygAjdanqw",
    "7nLJGsvxVUKEFIHRVK-DHbgLuH_BIdZaDiRImktkb68",
    "IZa8YcXoD9TasS9EoGj5_L0yg_csx7UIQq2I3QWELwI",
    "vyDjA2UggLj12tcFR-lKAo1kKaZyNeAM2twEJ62xkco",
    "HRut8B98Oe6pjs6OnZBfq93DhQVtRT9VfOER3e1-Ajg",
    "iEPkBNzZTNXSsEJUKL-RH5N1IkEf83EGWG2-L3kSa3s",
    "Ar1RAJDSAJdAGCI22nkAveDbtgtcMx1bNXopk2pfENs",
    "XUc8q12a_Me80D4TJopM0ruW4McTPTk1EChVHzNk1lM",
    "do9ABIDHoZmulTjymVF8tydHfrH5pZRVZuu4qm4aDV4",
    "dkVJmNCHFoChVBOrgYIv-XcCWTqg6q5HpkVk5zyyNdo",
    "2caOW6ol9T8LHCMO8tVAx4GHRwv1q3fFc79KzKOtoww",
    "HdZBZa0GfOEUYCubwvoSyxGUUgPmgy7RJb5l77T21bE",
    "7Dp5r-UpZLDvHqsDbZbqWhCBwbYdJMKBuC3tFC-FF7U",
    "EOtTxCGktZe_J2DTM0D5h04crjlpjgeygA1R6Pmo_qM",
    "92Tq6BKm6pvVkKW8_6Fb13QWTdUzBRLnG9scMBNWYZ4",
    "w27141UQGgrCFhkiw9tL7A0-qWMQjbapU3mq2TfI4Cg",
    "YLRkokEfrNNIZ8Pq5UUG2DaEdxJOgrOb9U5Bnhz4beY",
    "GATxiK4QNie39kefpC4xnyf8HWiEhFUQHEC_jy8oa3E",
    "NftYHZU3-6B-_FV-Ec4ctpR49Ulr8zsMN2oXd96MTG0",
    "qoUAMfYEBVOLQoQgqvbTyv302UVaFfl58jZow46sHhc",
    "XQkGzXG6YknJyy-YbakEZvQKAWkW2_aPRhc3ShC8lyA",
    "uOfZLIaT4qaLDXJau0twfkgqnPQhwm86Kjw02w1O3-g",
    "Z8HZq7c1VS6BxOvjCWvs46bnVaW_BepIoSy-v7KZn8E",
    "n_X3YTN7Wqxz5shER97Q6coFXGLdjFV1OVqhF_lIW78",
    "8zGVX17V6u3Uzn2fWJFya3vEuPOvIZ6FRifUDhaprtE",
    "Zwp7r7Z10O0TuF6lmFApB7m5lJIrE5RbLAVWg_WKNcU",
    "1enYq8LDJQ7fxW20WMWxbq3jpMaBeN-k67WXnhEDIds",
    "efrXSmKuDH32Svllu9g15PxTlxrL5T3UNT1jxgQqat0",
    "RM1oi-MA5gvJiznjAINPCCfcbN18RBgdXMOJcNoqkUM",
    "sTSWamZ22DNVQolWIc2L-Cfi88dC7YCE3dtXJwAa1kA",
    "42MB4-R4ra6HRk7xOK_JODbKzGQ3gvYjssXHERSTROU",
    "Qa9SzAuwJR6xZp3UiKzokKEoRnt_utJKjFjTaSR85Xw",
    "38TR3D8BxlPTc89NOW67IkQQUPR8jDLaJNdYv-4wWfM",
    "yWDo0H85PVimIpHM86qEP8BzXHIvyIfQE7NeVgTbhxs",
    "OrO8n453N6bx921wtsEs-0OCImBLCItNU5oSbFKlFuU",
    "-q2dbbzO7Gh0mh80Qh5dVTXfH9AC6XNPqawuNGtjzus"
  ];


(async () => {
  for (let i = 0; i < contracts.length; i++) {
    const contract = contracts[i];
    console.log(`Reading ${i + 1}/${contracts.length}: ${contract}`);
    const result = await readContract(
      arweave,
      contract,
      850127,
    );

    fs.writeFileSync(path.join(__dirname, 'contracts', `${contract}.json`), stringify(result));
  }
})();
