Skip to content

Instantly share code, notes, and snippets.

View kushti's full-sized avatar

Alexander Chepurnoy kushti

View GitHub Profile
data_point_source: NanoErgXau
oracle_contract_parameters:
ergo_tree_bytes: 100a040004000580dac409040004000e20472b4b6250655368566d597133743677397a24432646294a404d635166546a570402040204020402d804d601b2a5e4e3000400d602db63087201d603db6308a7d604e4c6a70407ea02d1ededed93b27202730000b2720373010093c27201c2a7e6c67201040792c172017302eb02cd7204d1ededededed938cb2db6308b2a4730300730400017305938cb27202730600018cb2720373070001918cb27202730800028cb272037309000293e4c672010407720492c17201c1a7efe6c672010561
pool_nft_index: 5
min_storage_rent_index: 2
min_storage_rent: 10000000
refresh_contract_parameters:
ergo_tree_bytes: 1016043c040004000e202a472d4a614e645267556b58703273357638792f423f4528482b4d625065536801000502010105000400040004020402040204080400040a05c8010e20472b4b6250655368566d597133743677397a24432646294a404d635166546a570400040404020408d80ed60199a37300d602b2a4730100d603b5a4d901036395e6c672030605eded928cc77203017201938cb2db6308720373020001730393e4c672030504e4c6720205047304d604b17203d605b0720386027305860273067307d90
object p2shTester extends App {
val p2shaddr = "4MQyML64GnzMxZgm"
val ae = ErgoAddressEncoder.Mainnet
val prop = ae.fromString(p2shaddr).get.script.toProposition(true)
val bs = ValueSerializer.serialize(prop)
val bac = ByteArrayConstant(bs)
ErgoTree(16,WrappedArray(IntConstant(1), IntConstant(0), IntConstant(1), IntConstant(0), IntConstant(0), LongConstant(1), LongConstant(0), LongConstant(1000), IntConstant(2), ConstantNode(Coll(-62,41,-52,18,-61,-101,120,-5,-103,-33,58,-128,51,40,-14,-71,-74,-25,-2,66,-80,-46,95,54,-45,-4,9,32,121,-50,-116,1),Coll[SByte$])),Right(BlockValue(WrappedArray(ValDef(1,WrappedArray(),MethodCall(Self$(167),SMethod(SBox,tokens,(SBox) => Coll[(Coll[SByte$],SLong$)],8,FixedCost(JitCost(15)),MethodIRInfo(Some(<function1>),None,None),Some(OperationInfo(Some(PropertyCall$(219)),Secondary tokens,ArrayBuffer(ArgInfo(this,this instance)))),None),WrappedArray(),Map())), ValDef(2,WrappedArray(),ByIndex(ValUse(1,Coll[(Coll[SByte$],SLong$)]),ConstantPlaceholder(0,SInt$),None)), ValDef(3,WrappedArray(),SelectField(ValUse(2,(Coll[SByte$],SLong$)),2)), ValDef(4,WrappedArray(),ByIndex(Outputs$(165),ConstantPlaceholder(1,SInt$),None)), ValDef(5,WrappedArray(),MethodCall(ValUse(4,SBox),SMethod(SBox,tokens,(SBox) => Coll[(Coll[SByte$],SL
{
// ===== Contract Information ===== //
// Name: Phoenix HodlCoin Bank
// Description: Contract for the bank box of the HodlCoin protocol.
// Version: 1.0.0
// Author: Luca D'Angelo (ldgaetano@protonmail.com), MGPai
// ===== Box Contents ===== //
// Tokens
@kushti
kushti / AdaptiveSimulator.scala
Created January 30, 2023 11:41
EIP-37 DAA simulator
package org.ergoplatform.tools
import org.ergoplatform.mining.difficulty.{DifficultyAdjustment, RequiredDifficulty}
import org.ergoplatform.modifiers.history.header.Header
import org.ergoplatform.settings.{Args, ErgoSettings, NetworkType}
import java.util.concurrent.TimeUnit
import scala.collection.mutable
import scala.concurrent.duration.FiniteDuration
import scala.util.Random
@kushti
kushti / FromSnapshot.scala
Created January 8, 2023 19:19
fromSnapshot functions removed from UtxoState (not used now)
def fromSnapshot(prover: BatchAVLProver[Digest32, HF],
settings: ErgoSettings) = {
val stateDir = ErgoState.stateDir(settings)
stateDir.mkdirs()
val constants = StateConstants(settings)
val store = new LDBVersionedStore(stateDir, initialKeepVersions = constants.keepVersions)
val version = store.get(bestVersionKey).map(w => bytesToVersion(w))
.getOrElse(ErgoState.genesisStateVersion)
val persistentProver: PersistentBatchAVLProver[Digest32, HF] = {
@kushti
kushti / light.cong
Last active February 3, 2022 21:53
ergo {
node {
keepVersions = 32
}
}
scorex {
network {
maxConnections = 10
}
object LeifHelp extends App {
val etBytes = Base16.decode("0008cd03e98b0082050a0878b6d1136f2d8cf5e24f7b6d025b2961bffaf5ca3a537a4f52").get
val v = Value.liftByteArray(etBytes)
val bs = ValueSerializer.serialize(v)
println("bs: " + Base16.encode(bs))
}
def reemissionBoxProp(s: MonetarySettings): ErgoTree = {
val rewardOut = ByIndex(Outputs, IntConstant(0))
val heightCorrect = EQ(boxCreationHeight(rewardOut), Height)
val heightIncreased = GT(Height, boxCreationHeight(Self))
val validPeriod = GE(Height, IntConstant(2080800))
val coinsToIssue = s.oneEpochReduction // 3 ERG
val correctCoinsIssued = EQ(coinsToIssue, Minus(ExtractAmount(Self), ExtractAmount(rewardOut)))
val sponsored = GT(ExtractAmount(rewardOut), ExtractAmount(Self))
package org.ergoplatform.wallet.serialization
import org.ergoplatform.{ErgoLikeTransactionSerializer, JsonCodecs}
import scorex.util.encode.Base16
object TransactionParser extends App {
val bytes = Base16.decode("...").get
val tx = ErgoLikeTransactionSerializer.fromBytes(bytes)
JsonCodecsWrapper.ergoLikeTransactionDecoder.decodeJson(j)