Code Monkey home page Code Monkey logo

Comments (8)

martriay avatar martriay commented on August 24, 2024

Yes. See https://docs.openzeppelin.com/nile/0.14.0/cli#deploy.

from nile.

Alpha2J avatar Alpha2J commented on August 24, 2024

Hello👏! I need to reopen this issue. According to the documentation, I tried to deploy my contract with the command nile deploy ACCOUNT_1 MyToken --alias mytoken_abc --network goerli mytoken_n mytoken_s 0x0468b7AdAE55BE128D1e10D13075A0FFF7e1941014F1C0aC780a35D51658965E. However, I encountered an error as shown in pic1. Additionally, I have included the constructor of my contract in pic2. Could you please check if there is any issue with my usage? I am new to Cairo and not very familiar with it.

image
image

from nile.

Alpha2J avatar Alpha2J commented on August 24, 2024

Before using the nile deploy command, I think it might be necessary to convert the string 'mytoken_n' for constructor to an integer type. However, I'm unsure about the exact method to do so and haven't been able to find any helpful documentation😞

from nile.

martriay avatar martriay commented on August 24, 2024

Short strings should be automatically converted, see: https://docs.openzeppelin.com/nile/0.14.0/strings#nile_integration

Alternatively you can use the str_to_felt utility.

from nile.

Alpha2J avatar Alpha2J commented on August 24, 2024

but it doesn't automatically converted:
image

from nile.

martriay avatar martriay commented on August 24, 2024

what version are you using? nile version

from nile.

Alpha2J avatar Alpha2J commented on August 24, 2024

0.14.0
image

and here is the stack trace:
image

from nile.

andrew-fleming avatar andrew-fleming commented on August 24, 2024

Hey @Alpha2J! My apologies, string arguments are unfortunately not supported in the latest release. Since we're no longer maintaining Nile, here's a script tailored to your project to help you deploy:

#scripts/my_token.py

from nile.utils import *

ALIAS = "mytoken_abc"
decimals = 18

async def run(nre):
    accounts = await nre.get_accounts()
    account = accounts[0]

    name = str_to_felt("mytoken_n")
    symbol = str_to_felt("mytoken_s")
    admin = 0x0468b7AdAE55BE128D1e10D13075A0FFF7e1941014F1C0aC780a35D51658965E

    arguments = [
        name,
        symbol,
        admin
    ]

    tx = await account.deploy_contract(
        "MyToken",
        salt=0,
        unique=0,
        calldata=arguments,
        alias=ALIAS
    )
    out = await tx.execute()
    print("MyToken deployed at", hex(out[1]))

    supply = await nre.call(ALIAS, "totalSupply")
    print("total supply:", from_decimals(supply))

    name = await nre.call(ALIAS, "name")
    print("token name:", int_to_str(name))

    symbol = await nre.call(ALIAS, "symbol")
    print("token symbol:", int_to_str(symbol))

def from_decimals(x):
    split_str = x.split()
    y = from_uint([int(item, 16) for item in split_str])
    return y / (10 ** decimals)

def to_decimals(x):
    return x * (10 ** decimals)

def from_hex(x):
    return int(x, 16)

def int_to_str(x):
    return felt_to_str(x)

Run this with nile run scripts/my_token.py. I hope this helps :)

from nile.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.