Giter Club home page Giter Club logo

examples's People

Contributors

chenzhitong avatar cloud8little avatar erikzhang avatar igormcoelho avatar longfeiwan9 avatar shargon avatar superboyiii avatar tanziwen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

examples's Issues

"Oracle response failure with code " - need to set Content-Type header to application/json

Hi!

I'm trying to call the NEO Oracle using the sample smart contract below:

using Neo.SmartContract.Framework.Services;
using Neo.SmartContract.Framework.Attributes;
using Neo.SmartContract.Framework.Native;
using System;

namespace Neo.SmartContract.Examples
{
    [ManifestExtra("Author", "Neo")]
    [ManifestExtra("Email", "[email protected]")]
    [ManifestExtra("Description", "This is an oracle example")]
    public class OracleDemo : Framework.SmartContract
    {
        public static void doRequest()
        {
            string url = "https://raw.githubusercontent.com/neo-project/examples/master/csharp/Oracle/example.json"; // the content is  { "value": "hello world" }
            string filter = "$.value";  // JSONPath format https://github.com/atifaziz/JSONPath
            string callback = "callback"; // callback method
            object userdata = "userdata"; // arbitrary type
            long gasForResponse = Oracle.MinimumResponseFee;`

            Oracle.Request(url, filter, callback, userdata, gasForResponse);
        }

        public static void callback(string url, string userdata, OracleResponseCode code, string result)
        {
            if (Runtime.CallingScriptHash != Oracle.Hash) throw new Exception("Unauthorized!");
            if (code != OracleResponseCode.Success) throw new Exception("Oracle response failure with code " + (byte)code);

            object ret = StdLib.JsonDeserialize(result); // [ "hello world" ]
            object[] arr = (object[])ret;
            string value = (string)arr[0];

            Runtime.Log("userdata: " + userdata);
            Runtime.Log("response value: " + value);
        }
    }
}

However, I'm getting a message that the Oracle is failing: "Oracle response failure with code "

Per asking people on Discord, the key issue is that the Oracle website isn't setting Content-Type header to application/json. Instead its setting it to text/plain; charset=utf-8. Per the blockchain explorer, transaction had an exception VMState == FAULT error is ContentTypeNotSupported.

However, I cannot make this change from my end, it needs to be done from the website.

Can someone here please confirm that this is the root cause of the error, and if so, provide a work-around or fix the problem directly on the Oracle website? For reference, my smart contract is deployed on TestNet here, if you'd like to test it directly:

https://dora-dev.coz.io/transaction/neo3/testnet/0xc94e32026d03e2b5408bd28cd7b9e9022a3b08fe9337d94a366563870c02dd5a

Thanks,

Please write a template for VB.NET

I've tried everything I can think of to create a VB.NET version of the C# template, but I always end up with something like this in the output:

1>CONVERTTASK : Convert error : System.Exception: unknown call:System.String ExternalTest.TestFunctions::Main()
1> at Neo.Compiler.MSIL.ModuleConverter._ConvertCall(OpCode src, AntsMethod to)
1> at Neo.Compiler.MSIL.ModuleConverter.ConvertCode(ILMethod method, OpCode src, AntsMethod to)
1> at Neo.Compiler.MSIL.ModuleConverter.ConvertMethod(ILMethod from, AntsMethod to)
1> at Neo.Compiler.MSIL.ModuleConverter.Convert(ILModule _in)
1> at Neo.Compiler.Program.Main(String[] args)

Error when building ICO_Template

To whom it may concern,
I checked out repos at the latest commit 3544cc42d4c9c8f868ce22dca51f83af0fccf744
When building ICO_Template project this error occurs:

1>------ Rebuild All started: Project: ICO_Template, Configuration: Debug Any CPU ------
1>  ICO_Template -> C:\workspace\examples-csharp\ICO_Template\bin\Debug\ICO_Template.dll
1>  Start NeoContract converter, Source File: C:\workspace\examples-csharp\ICO_Template\bin\Debug\ICO_Template.dll
1>  Neo.Compiler.MSIL console app v2.0.3.0
1>CONVERTTASK : LoadModule error : System.Exception: can't parese event type from:System.Action`3<System.Byte[],System.Byte[],System.Numerics.BigInteger>.maybe it is System.Action<xxx> which is defined in mscorlib.dll,copy this dll in.
1>     at Neo.Compiler.MSIL.ILField..ctor(ILType type, FieldDefinition field)
1>     at Neo.Compiler.MSIL.ILType..ctor(ILModule module, TypeDefinition type)
1>     at Neo.Compiler.MSIL.ILModule.LoadModule(Stream dllStream, Stream pdbStream)
1>     at Neo.Compiler.Program.Main(String[] args)
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========

My system specs:

Windows 10 Education
MS Visual Studio Professional 2017 - Version 15.4.5
MS .NET Framework Version 4.7.02053

Could you please take a look into this issue?

One more thing, I'm new in NEO world and looking for a tutorial/example to implement an ICO, like https://aphelion.org/
Is there any more detailed example/tutorial for newbie to understand and follow?

Many thanks,

Impossible to see return values for Domain

Due to current limitations it is not currently possible to get the return value out to see if the Domain smart contract is working properly e.g. (have you registered a Domain or transferred it).

The solution is to use Runtime.Log, I am working on amending the code to be able to add the logging in which will help people understand their smart contracts.

ICO_Template.cs does not comply with the NEP-5 specification

@erikzhang

https://github.com/neo-project/examples-csharp/blob/master/ICO_Template/ICO_Template.cs does not comply with the NEP-5 specification. For example all of the public NEP-5 methods should start with a lower case letter. There's issues with the lettercasing of the transfer event.

The sample also contains operations and methods that are extraneous to the NEP-5 specification.

The sample doesn't comply with NEP-10 in light of the above.

Reference:
neo-project/proposals#33

neo-project/proposals#44 (comment)

Asset is not registered after deploying ICO_Template

Hi, I want to implement a token for ICO base on NEO, so follow this template.
After getting avm file, I deployed and invoked deploy method as described in this guide.

I followed the tutorial carefully and no error occurred. But my token just does not appear in testnet's assets list. I also see in the test net there's no asset that has type NEP5 now.

I want to implement a token like APH in main net, but don't have any clues how to make it now.
Did I miss any step? Or NEP5 token is not available in test net?
Best regards,

ICO template building error

I'm getting "System.InvalidOperationException: Stack empty." error when compiling the ICO template project.
My .net framework version is 4.7.1 and I've already copied mscorlib.dll to the ICO_Template\bin\Debug folder.

Smart contracts for deployment

You mentioned the contract for intelligent deployment to block chain for other people to call in the intelligent contract document, how to deploy?

typo in domain contract sample

return Transfer((string)args[0], (byte[])args[1], (byte[])args[2], (byte[])args[2]);
should probably be
return Transfer((string)args[0], (byte[])args[1], (byte[])args[2], (byte[])args[3]);

Unable to compile project

I see the below errors. Please help me.

Using neo.smartcontract.framework\3.0.0-preview5

error CS0246: The type or namespace name 'ContractPermissionAttribute' could not be found (are you missing a using directive or an assembly reference?)
error CS0246: The type or namespace name 'ContractPermission' could not be found (are you missing a using directive or an assembly reference?)

ICO_Template has overfunding bug

It is possible to overfund the ICO with the current code.

The current MintTokens() method checks using CurrentSwapRate() whether or not Total_Supply >= Total_Amount however it doesn't check if receiving this incoming NEO asset will take the Total_Supply over the amount raised.

This has the unlikely but possible situation that the last person to input assets could have sent a huge amount of NEO which means they will overfund the ICO and receive loads of tokens.

I have a fix for this so raising this as an issue which I've been working on.

Error when build ...

Start NeoContract converter, Source File: E:\nep17test\bin\Debug\net5.0\FJBC.dll
Neo.Compiler.MSIL console app v3.0.0.0
EXEC : Convert error : System.Exception: error:System.Void FJBC.NEP17::Mint(System.Numerics.BigInteger)::IL_0047 Call Neo.SmartContract.Framework.IScriptContainer Neo.SmartContract.Framework.Services.System.ExecutionEngine::get_ScriptContainer()(43) [E:\nep17test\FJBC.csproj]
---> System.NullReferenceException: Object reference not set to an instance of an object.
at Neo.Compiler.MSIL.ModuleConverter.TryInsertMethod(NeoModule outModule, MethodDefinition method) in C:\Users\erik\source\repos\neo-project\neo-devpack-dotnet\src\Neo.Compiler.MSIL\MSIL\Conv_Multi.cs:line 1175
at Neo.Compiler.MSIL.ModuleConverter.ConvertCall(OpCode src, NeoMethod to, List`1 methodTokens) in C:\Users\erik\source\repos\neo-project\neo-devpack-dotnet\src\Neo.Compiler.MSIL\MSIL\Conv_Multi.cs:line 772
at Neo.Compiler.MSIL.ModuleConverter.ConvertCode(ILMethod method, OpCode src, NeoMethod to) in C:\Users\erik\source\repos\neo-project\neo-devpack-dotnet\src\Neo.Compiler.MSIL\MSIL\Converter.cs:line 805
at Neo.Compiler.MSIL.ModuleConverter.FillMethod(ILMethod from, NeoMethod to, Boolean withReturn) in
C:\Users\erik\source\repos\neo-project\neo-devpack-dotnet\src\Neo.Compiler.MSIL\MSIL\Converter.cs:line 277
--- End of inner exception stack trace ---
at Neo.Compiler.MSIL.ModuleConverter.FillMethod(ILMethod from, NeoMethod to, Boolean withReturn) in
C:\Users\erik\source\repos\neo-project\neo-devpack-dotnet\src\Neo.Compiler.MSIL\MSIL\Converter.cs:line 281
at Neo.Compiler.MSIL.ModuleConverter.Convert(ILModule _in, ConvOption option) in C:\Users\erik\source\repos\neo-project\neo-devpack-dotnet\src\Neo.Compiler.MSIL\MSIL\Converter.cs:line 124
at Neo.Compiler.Program.Compile(Options options, ILogger log) in C:\Users\erik\source\repos\neo-project\neo-devpack-dotnet\src\Neo.Compiler.MSIL\Program.cs:line 165
... ...

can not build project success

I can not build examples, the detail messages is here:

c:\examples-csharp-master\ICO_Template 的目录

2017/12/18  12:05    <DIR>          .
2017/12/18  12:05    <DIR>          ..
2017/12/18  13:32    <DIR>          bin
2017/10/18  00:16               199 build.tasks
2017/10/18  00:16             9,976 ICO_Template.cs
2017/10/18  00:16             2,707 ICO_Template.csproj
2017/10/18  00:16             6,656 Neo.ConvertTask.dll
2017/12/18  13:32    <DIR>          obj
2017/10/18  00:16               152 packages.config
2017/12/18  12:04    <DIR>          Properties
               5 个文件         19,690 字节
               5 个目录 16,678,305,792 可用字节

c:\examples-csharp-master\ICO_Template>msbuild
用于 .NET Framework 的 Microsoft (R) 生成引擎版本 15.5.180.51428
版权所有(C) Microsoft Corporation。保留所有权利。

生成启动时间为 2017/12/18 13:39:33。
节点 1 上的项目“c:\examples-csharp-master\ICO_Template\ICO_Template.csproj”(默认目标)。
GenerateTargetFrameworkMonikerAttribute:
正在跳过目标“GenerateTargetFrameworkMonikerAttribute”,因为所有输出文件相对于输入文件而言都是最新的。
CoreCompile:
正在跳过目标“CoreCompile”,因为所有输出文件相对于输入文件而言都是最新的。
_CopyFilesMarkedCopyLocal:
  正在对“c:\examples-csharp-master\ICO_Template\obj\Debug\ICO_Template.csproj.CopyComplete”执行 Touch 任务。
CopyFilesToOutputDirectory:
  ICO_Template -> c:\examples-csharp-master\ICO_Template\bin\Debug\ICO_Template.dll
AfterBuild:
  Start NeoContract converter, Source File: c:\examples-csharp-master\ICO_Template\bin\Debug\ICO_Template.dll
已完成生成项目“c:\examples-csharp-master\ICO_Template\ICO_Template.csproj”(默认目标)的操作 - 失败。


生成失败。
    0 个警告
    0 个错误

已用时间 00:00:01.39

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.